Snapshots and Backups
There are two levels of protection: snapshots (instant copy of the entire server) and backups (copy of individual files or databases).
Snapshots from panel
Snapshots are complete copies of your server's disk at a specific point in time. They allow you to restore your server to a previous state in just a few minutes.
When to use a snapshot:
How to create a snapshot:
Snapshots take up space in your plan. Check the maximum number of snapshots available for your plan and delete old ones when no longer needed.
- Before critical system updates
- Before installing new software
- Before configuration changes
- Log into the control panel
- Select your server
- Go to Snapshots or Backups
- Click Create Snapshot
Manual file backup with `rsync`
To backup your files to a remote server or locally:
rsync -avz --progress /path/to/backup/ user@backup-server:/destination/path/
Example: backup /var/www folder:
rsync -avz /var/www/ backup@192.168.1.100:/backups/www/
Automatic backup with cron
To schedule a daily backup:
crontab -e
Add:
# Daily backup at 03:00
0 3 * * * rsync -az /var/www/ backup@IP_BACKUP:/backups/www/ >> /var/log/backup.log 2>&1
MySQL/MariaDB database backup
# Backup all databases
mysqldump --all-databases -u root -p > /root/backup_db_$(date +%Y%m%d).sql
# Backup a single database
mysqldump -u root -p database_name > /root/backup_database_$(date +%Y%m%d).sql
To compress the backup:
mysqldump -u root -p database_name | gzip > /root/backup_$(date +%Y%m%d).sql.gz
Restore from database backup
# From .sql file
mysql -u root -p database_name < /root/backup.sql
# From .sql.gz file
gunzip < /root/backup.sql.gz | mysql -u root -p database_name
Backup with BorgBackup (advanced solution)
BorgBackup is a professional tool with deduplication and encryption:
# Installation
apt install borgbackup
# Initialize the repository
borg init --encryption=repokey user@backup-server:/backups/borg
# Create a backup
borg create user@backup-server:/backups/borg::$(date +%Y-%m-%d) /var/www /etc
# List of backups
borg list user@backup-server:/backups/borg
Articoli correlati
Server Reboot
How to properly restart your VPS or VDS, both via SSH and from the control panel
Resource Monitoring
How to check CPU, RAM, disk and network on your server in real time
Disk Management
How to check disk space, find large files and free up disk space
