Regular automated backups protect your VPS from data loss. This guide covers setting up cron-based backups and off-server storage.
Automated Database Backups
Create a backup script at /root/backup-db.sh:
#!/bin/bash\nDATE=$(date +%Y%m%d)\nmysqldump -u root -pYOUR_PASSWORD --all-databases | gzip > /backups/db-$DATE.sql.gz\n# Delete backups older than 7 days\nfind /backups -name "db-*.sql.gz" -mtime +7 -deleteMake executable: chmod +x /root/backup-db.sh. Schedule with cron: 0 2 * * * /root/backup-db.sh
File Backups with rsync
Sync web files to a remote backup server daily:
rsync -avz --delete /var/www/ backup-user@backup-server:/backups/www/Set up SSH key authentication between servers so this runs unattended in a cron job.
VPS Snapshots
Your Double Hosting dashboard lets you take VPS snapshots β full disk images. Go to your VPS management panel and click Create Snapshot. Snapshots can restore the entire server to a previous state in minutes. Take a snapshot before major changes.