Skip to main content

VPS Snapshots & Backups

Protect your VPS instances with automated snapshots and backup strategies for disaster recovery and system restoration.

Quick Startโ€‹

Create Manual Snapshotโ€‹

# Create snapshot
lineserve compute create-snapshot \
--instance-id vps-12345678 \
--name "pre-deployment-backup"

# Create consistent snapshot (with power-off)
lineserve compute create-snapshot \
--instance-id vps-12345678 \
--name "consistent-backup" \
--power-off

Enable Automated Backupsโ€‹

# Daily backups with 7-day retention
lineserve compute enable-auto-backup \
--instance-id vps-12345678 \
--frequency daily \
--retention 7 \
--time "02:00"

Database Backupsโ€‹

MySQLโ€‹

# Backup script
mysqldump -u root -p myapp > backup_$(date +%Y%m%d).sql
gzip backup_$(date +%Y%m%d).sql
lineserve storage upload backup_*.sql.gz s3://backups/

PostgreSQLโ€‹

# Backup script
pg_dump myapp > backup_$(date +%Y%m%d).sql
gzip backup_$(date +%Y%m%d).sql
lineserve storage upload backup_*.sql.gz s3://backups/

File Backupsโ€‹

Rsyncโ€‹

# Incremental backup
rsync -avz --delete /var/www/html/ user@backup-server:/backups/web/

Tar Archiveโ€‹

# Compressed archive
tar -czf backup_$(date +%Y%m%d).tar.gz /etc /var/www /home
lineserve storage upload backup_*.tar.gz s3://backups/

Restorationโ€‹

From Snapshotโ€‹

# Restore existing VPS
lineserve compute restore-instance \
--instance-id vps-12345678 \
--snapshot-id snap-87654321

# Create new VPS from snapshot
lineserve compute create-instance \
--snapshot-id snap-87654321 \
--plan standard-2

Database Restoreโ€‹

# MySQL
mysql -u root -p myapp < backup.sql

# PostgreSQL
psql -U postgres myapp < backup.sql

Automationโ€‹

Cron Jobsโ€‹

# Daily database backup at 2 AM
0 2 * * * /scripts/backup-db.sh

# Weekly file backup on Sundays
0 3 * * 0 /scripts/backup-files.sh

Backup Script Exampleโ€‹

#!/bin/bash
# backup.sh
DATE=$(date +%Y%m%d)

# Database backup
mysqldump -u root -p$DB_PASSWORD myapp | gzip > db_$DATE.sql.gz

# File backup
tar -czf files_$DATE.tar.gz /var/www/html

# Upload to storage
lineserve storage upload db_$DATE.sql.gz s3://backups/
lineserve storage upload files_$DATE.tar.gz s3://backups/

# Clean old local backups
find /backups -name "*.gz" -mtime +7 -delete

Best Practicesโ€‹

Backup Strategy (3-2-1 Rule)โ€‹

  • 3 copies of data
  • 2 different storage types
  • 1 offsite backup

Frequency Guidelinesโ€‹

  • Critical systems: Every 4-6 hours
  • Production: Daily
  • Development: Weekly

Testingโ€‹

# Test backup integrity
lineserve compute test-restore \
--snapshot-id snap-12345678 \
--auto-terminate 1h

Monitoringโ€‹

Check Backup Ageโ€‹

# Alert if backup older than 25 hours
LATEST=$(lineserve compute list-snapshots --instance-id vps-12345678 --format json | jq -r '.[0].created_at')
AGE_HOURS=$(( ($(date +%s) - $(date -d "$LATEST" +%s)) / 3600 ))
[ $AGE_HOURS -gt 25 ] && echo "ALERT: Backup is $AGE_HOURS hours old"

Pricingโ€‹

  • Snapshots: First 10GB free, then $0.05/GB/month
  • Automated backups: $2/month per VPS
  • Cross-region replication: $0.02/GB transferred

Cross-Region Disaster Recoveryโ€‹

# Enable cross-region backup
lineserve compute enable-cross-region-backup \
--instance-id vps-12345678 \
--target-region eu-west-1 \
--frequency daily

# Create DR instance
lineserve compute create-instance \
--snapshot-id snap-dr-12345678 \
--region eu-west-1