How to Back Up Your VPS (Snapshots vs File Backups)

Estimated reading: 3 minutes

Backups are the most important thing you can set up on a VPS — and they’re also the most ignored until something breaks. This guide covers all three backup strategies for your VeerHost VPS: VeerHost snapshots, manual file backups, and automated daily backups using cron.

Method 1: VeerHost Control Panel Snapshots

The fastest way to create a full backup. A snapshot captures the entire disk state at that moment — OS, configs, files, and databases.

  • Log in to your VeerHost client area
  • Go to Services > My VPS
  • Click Snapshots and create a new snapshot
  • To restore, select the snapshot and click Restore

Best for: Before major changes (OS updates, new software installs, config changes). Always take a snapshot before anything risky.

Method 2: Manual File Backup with tar

Create a compressed archive of your website files or any directory:

# Backup a website directory
tar -czvf /root/backup-$(date +%Y-%m-%d).tar.gz /var/www/yourdomain.com

List the contents of a backup to verify it:

tar -tzvf /root/backup-2026-03-31.tar.gz | head -20

Restore from the backup:

tar -xzvf /root/backup-2026-03-31.tar.gz -C /

Method 3: MySQL Database Backup

Always back up databases separately from files. File backups do not include MySQL data.

Backup a single database:

mysqldump -u root -p mywebsite > /root/mywebsite-$(date +%Y-%m-%d).sql

Backup all databases:

mysqldump -u root -p --all-databases > /root/all-databases-$(date +%Y-%m-%d).sql

Restore a database:

mysql -u root -p mywebsite < /root/mywebsite-2026-03-31.sql

Method 4: Download Backup to Your Local Machine

A backup stored on the same VPS it came from is not a real backup. Download it to your local computer:

# Run this on your LOCAL machine (not the server)
scp root@YOUR_VPS_IP:/root/backup-2026-03-31.tar.gz ~/Downloads/

Or use rsync for incremental backups (only copies changed files):

rsync -avz root@YOUR_VPS_IP:/var/www/ ~/vps-backups/www/

Method 5: Automated Daily Backups with Cron

Create a backup script and schedule it to run automatically every night:

nano /root/backup.sh

Paste this script:

#!/bin/bash
DATE=$(date +%Y-%m-%d)
BACKUP_DIR=/root/backups

mkdir -p $BACKUP_DIR

# Backup website files
tar -czvf $BACKUP_DIR/www-$DATE.tar.gz /var/www/

# Backup MySQL databases
mysqldump -u root -pYOUR_MYSQL_PASSWORD --all-databases > $BACKUP_DIR/mysql-$DATE.sql

# Delete backups older than 7 days
find $BACKUP_DIR -name "*.tar.gz" -mtime +7 -delete
find $BACKUP_DIR -name "*.sql" -mtime +7 -delete

echo "Backup completed: $DATE"

Make it executable and test it:

chmod +x /root/backup.sh
/root/backup.sh

Schedule it to run daily at 2 AM via cron:

crontab -e

Add this line at the bottom:

0 2 * * * /root/backup.sh >> /root/backup.log 2>&1

Snapshots vs File Backups: Which to Use?

SnapshotsFile Backups
What's includedFull disk (OS + files + DB)Only what you specify
Speed to createFast (minutes)Depends on size
Speed to restoreFast (full restore)Manual restore
Off-server copyStored by VeerHostMust download yourself
Best forBefore risky changesDaily automated backups