Production Backup Architect
You are running a Next.js application on an Interserver VPS with PostgreSQL. This interactive guide synthesizes research on high-uptime backup strategies, focusing on the "3-2-1" rule and automated off-site storage using standard Linux tools.
The 3-2-1 Rule Compliance
Target StateCopies of Data
1. Production DB (Live)
2. Local Backup (Staging)
3. Off-site Backup (S3/Cloud)
Different Media
SSD (VPS Disk) vs. Object Storage (Cold Storage)
Off-site Copy
Physically separate from Interserver datacenters (e.g., AWS us-east-1).
Strategy Trade-offs
Balancing Data Loss Risk (RPO) vs. Implementation Complexity.
PostgreSQL Uptime Priority
The primary concern is backing up without stopping the app.
We use pg_dump with the directory format or custom format to ensure consistency without table locking.
Strategy A: Automated Daily Dumps
Recommended
Uses pg_dump to create a snapshot.
Pros: Simple, portable, reliable. Zero downtime.
Cons: Data loss limited to time since last dump (e.g., 24hrs).
Strategy B: Continuous WAL Archiving
Enterprise
Streams "Write Ahead Logs" to storage (e.g., using Wal-G).
Pros: Near zero data loss (RPO ~seconds).
Cons: High complexity, harder restore process, higher storage use.
Recovery Time Comparison (Simulated)
Based on a 10GB Database size.
The Next.js Filesystem
/node_modules(Reinstallable)/.next(Build artifact)/.git(In repo)
.env(Secrets)/public/uploads(User content)/config(Custom server configs)
Use Rclone. It's the standard for VPS-to-Cloud sync.
Off-Site Storage Cost Estimator (Monthly)
Comparing 100GB of daily backups retention.
Bash Script Generator
Configure your daily backup script parameters below.
Reduces size by ~80%
Essential for PII/compliance
Off-site redundancy
Delete local files older than 7 days
#!/bin/bash
# Generated Backup Script
# Variables
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/var/backups/postgres"
DB_NAME="production_db"
mkdir -p $BACKUP_DIR
# 1. Database Dump
pg_dump -Fc $DB_NAME > "$BACKUP_DIR/$DB_NAME-$TIMESTAMP.dump"