Your VPS holds your website, your databases, your email and months of setup work. One wrong command, a hacked plugin or a data centre fire can wipe it all out. This VPS backup guide explains how backups and snapshots protect that data and how to bring your server back when something breaks.
You'll learn what a snapshot actually is, why it isn't a backup, which tools work best for automatic VPS backup, and how to restore a VPS from backup step by step.
Key takeaway:
A snapshot is a fast, point-in-time copy of your whole VPS disk. Use it before updates. It usually stays on your provider's platform, often in the same data centre.
A backup is a separate copy of your files and databases. It should live off-site, keep weeks or months of history, and be tested regularly.
The safest setup uses both. Snapshots give you a quick rollback, and encrypted off-site backups made with restic, Borg or rsync give you real disaster recovery.
Restore a test copy every month. Until you've done that, you don't know your backup works.
This guide is for website owners, developers and small businesses running a Linux VPS, whether it's a BDIX VPS in Bangladesh or a global VPS abroad. The case studies link to public post-mortems and news reports, and the commands follow each tool's documentation. Test them on your own server before you rely on them.
A Completed VPS Setup Guide For You
Short answer: decide what to save, export your databases, copy everything to storage outside your VPS, schedule it, and test a restore.
List what matters. On most Linux servers that means /etc (configs), /var/www or your app folder, /home, SSL certificates, cron jobs and your databases.
Export your databases first. Copying live MySQL or PostgreSQL data files can give you a broken copy. Export them instead (full commands are in the script further down):
MySQL/MariaDB: use mysqldump with --routines --triggers --events, so stored procedures, triggers and scheduled events are saved along with your tables.
PostgreSQL: run pg_dumpall as the postgres superuser, so it can read every database plus roles and permissions.
Choose a destination outside the server. That could be a second VPS (a Storage VPS works well), S3-compatible object storage, or a backup server in another location. Never keep your only copy on the same machine.
Pick a tool. Use rsync for simple file copies, or restic or Borg for encrypted, versioned backups. They're compared below.
Automate it. Schedule the job with cron or a systemd timer so it runs every night.
Set retention. For example, keep 7 daily, 4 weekly and 6 monthly copies so you can go back to before a hidden problem started.
Monitor and test. Set up an alert for failed jobs, and do a test restore every month.
A backup on the same server works like a spare house key kept inside the locked house. It needs to be somewhere else, and you need to know it opens the door.
Short answer: no. A snapshot is a fast, point-in-time image of your VPS disk, usually stored on your hosting provider's platform. A backup is an independent copy of your data, ideally kept somewhere else, with older versions you can go back to.
Here's the VPS snapshot explained simply. The hypervisor or storage layer (for example KVM/QEMU disk images, LVM or ZFS, depending on the provider) freezes the disk at one moment. If an update breaks your site, you can roll back in minutes. That makes snapshots ideal just before an OS upgrade, a PHP version change or a big plugin update.
Snapshots have two limits:
They depend on the platform they came from. If the provider's storage fails, your account is suspended, or the data centre goes offline, your snapshots can go with it.
They're usually only crash-consistent. A snapshot of a running database captures the disk as if the power had been cut. Databases normally recover from that, but a proper database dump is the safer copy.
Verdict: you don't have to choose between a snapshot and a backup. Use snapshots for quick rollbacks and off-site backups for recovery.
Short answer: make one full backup, then run incremental backups that save only what changed. restic and Borg do this automatically.
Full backup: copies everything every time. It's easy to restore but slow and uses a lot of storage.
Incremental backup: copies only the changes since the last run. It's fast and small, and with deduplicating tools like restic and Borg, each saved version can still be restored on its own.
Short answer: long enough to go back to before the problem started. A common starting point is 7 daily, 4 weekly and 6 monthly copies. Adjust it to how often your data changes and to any legal record-keeping rules your business has.
Some problems stay hidden. An infected file or a corrupted table can go unnoticed for weeks. If you only keep last night's copy, restoring it just brings the damage back.
Short answer: keep 3 copies of your data on 2 different types of storage, with 1 copy in a geographically separate location. The US Cybersecurity and Infrastructure Security Agency (CISA) recommends this rule in its Data Backup Options guide.
All three parts matter:
3 copies: your live data plus two backups. Having one copy fail is survivable, but having both backups fail at once is unlikely.
2 storage types: the copies shouldn't share one weak point. For example, keep one on a separate backup server's disks and another in object storage, not both on the same storage system.
1 off-site copy: at least one copy in a different data centre or region, ideally with a different provider, so a fire, flood or account problem can't destroy every copy.
Snapshots don't count toward 3-2-1. A snapshot on the same VPS, the same storage platform or in the same data centre fails together with your server. Treat it as a quick rollback tool, not an independent disaster-recovery copy.
A 3-2-1 setup for a VPS could look like this:
Copy 1: your live VPS (plus snapshots for quick rollbacks)
Copy 2: an encrypted restic or Borg repository on a separate backup server, such as a Storage VPS in a different data centre
Copy 3: a second encrypted copy in S3-compatible object storage with another provider or in another region, set up as immutable or append-only
Ransomware has made that last copy even more important. Attackers increasingly look for backups and delete them first, which is why newer versions of the rule, such as 3-2-1-1-0, add an immutable copy and backups verified to restore with zero errors. On a VPS you can get close to this with an append-only repository that your web server can add to but can't delete from, plus regular restore tests.
Short answer: for most Linux VPS users, restic or Borg is the best all-round choice, and rsync is fine for simple file mirroring. Use provider snapshots on top for quick rollbacks.
rsync copies files to another server over SSH. It's simple and comes preinstalled on most Linux systems.
rsync -aAX --delete /var/www/ backup@backup-server:/backups/www/Be careful with --delete. It keeps the mirror identical to your server, so a file you delete by mistake, or a file ransomware encrypts, is wiped or overwritten in the backup on the next run. A plain rsync mirror is a copy, not a backup. It keeps only one version, and that version can already be damaged.
If you use rsync, add versions. One way is a new dated folder each night, with --link-dest hard-linking unchanged files to the previous night's folder so they don't take up extra space:
TODAY=$(date +%F)
rsync -aAX --delete --link-dest=/backups/www/latest /var/www/ backup@backup-server:/backups/www/$TODAY/
ssh backup@backup-server "ln -sfn /backups/www/$TODAY /backups/www/latest"
You'll still need to delete old folders yourself, and nothing is encrypted. For most VPS owners, a versioned backup tool like restic or Borg is the simpler and safer choice.
restic encrypts and deduplicates your data and keeps a history of snapshots.
Step 1: Store the password in a protected file. Don't type the repository password into commands or into crontab, where it can end up in shell history, process lists or logs. Generate a random password, save it in a file only root can read, and keep a second copy in your password manager:
openssl rand -base64 32 > /root/.restic-password
chmod 600 /root/.restic-password
restic reads the password from the file named in the RESTIC_PASSWORD_FILE environment variable, and the repository location from RESTIC_REPOSITORY.
Step 2: Create the repository once.
export RESTIC_REPOSITORY="sftp:backup@backup-server:/srv/restic-repo"
export RESTIC_PASSWORD_FILE="/root/.restic-password"
restic init
Step 3: Write a backup script that fails loudly. GitLab's backups failed without anyone knowing. This script stops at the first error and reports both success and failure to a monitoring URL:
#!/usr/bin/env bash
# /usr/local/bin/vps-backup.sh (chmod 700, owned by root)
set -euo pipefail
export RESTIC_REPOSITORY="sftp:backup@backup-server:/srv/restic-repo"
export RESTIC_PASSWORD_FILE="/root/.restic-password"
ALERT_URL="https://your-monitoring-service.example/your-check-id" # replace with your own
# Report failure on any error
on_exit() {
status=$?
if [ "$status" -ne 0 ]; then
curl -fsS -m 10 --retry 3 "$ALERT_URL/fail" >/dev/null || true
fi
}
trap on_exit EXIT
# 1. Make sure there is room for the database dumps (5 GB here; adjust to your size)
avail_kb=$(df --output=avail /backup | tail -1)
if [ "$avail_kb" -lt 5000000 ]; then
echo "Not enough free space in /backup" >&2
exit 1
fi
# 2. Database dumps. MySQL credentials come from /root/.my.cnf (chmod 600), not the command line
mysqldump --single-transaction --routines --triggers --events \
--all-databases > /backup/mysql.sql
sudo -u postgres pg_dumpall > /backup/postgres.sql # remove the line you don't need
# 3. Back up, apply retention, check repository integrity
restic backup /etc /var/www /home /backup
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
restic check
# 4. Report success
curl -fsS -m 10 --retry 3 "$ALERT_URL" >/dev/null || true
A few notes on the script:
MySQL login: put the backup user's credentials in /root/.my.cnf under a [client] section and run chmod 600 on it. On many MariaDB installs, root can also log in through the local socket with no password at all. --single-transaction gives a consistent dump for InnoDB tables, but not for older MyISAM tables.
PostgreSQL: pg_dumpall needs superuser rights, which is why it runs as the postgres user. If you connect over the network, use a ~/.pgpass file instead of a password on the command line. Run the command by hand once to confirm the login and permissions work.
Alerts: use a "dead man's switch" style monitoring service that expects a success ping every night. If no ping arrives, because the server crashed or the job never ran, it alerts you. That covers silent failures a plain error email would miss.
Disk space on the backup side: check free space on the backup server or storage bucket regularly. restic stats shows how big the repository is, and you should set an alert for when that disk gets close to full.
The same rules apply to Borg: keep the passphrase in a protected file, never in the command itself.
export BORG_REPO="backup@backup-server:/srv/borg-repo"
export BORG_PASSCOMMAND="cat /root/.borg-passphrase" # file is chmod 600
borg init --encryption=repokey
borg key export "$BORG_REPO" /root/borg-key-backup.txt # move this file off the server
borg create ::'{hostname}-{now}' /etc /var/www /home /backup
borg prune --keep-daily 7 --keep-weekly 4 --keep-monthly 6
With repokey encryption, the key is stored inside the repository. Keep both the exported key and the passphrase somewhere off the server. If you lose either one, the backups can't be opened.
Make the repository append-only. On the backup server, you can limit your VPS's SSH key so it can add new backups but can't delete old ones. Do this in the backup server's ~/.ssh/authorized_keys file:
command="borg serve --append-only --restrict-to-path /srv/borg-repo",restrict ssh-ed25519 AAAA... vps-backupIf an attacker takes over your VPS, they can't wipe your backup history with that key. Run borg prune and borg compact from the backup server itself, or with a separate key the VPS doesn't have. restic gets similar protection when its rest-server backend runs in --append-only mode.
These examples use Borg 1.x syntax. Borg 2 changes some commands, so check the docs for the version you install.
If a backup is still running when the next one starts, the two can slow each other down or collide. flock prevents that by skipping a run while the previous one is still going:
30 2 * * * flock -n /var/lock/vps-backup.lock /usr/local/bin/vps-backup.sh >> /var/log/vps-backup.log 2>&1
A skipped run doesn't trigger an error alert, but because no success ping arrives, the dead-man's-switch monitor still warns you.
A successful backup command only proves the data was sent. To check you can get it back:
Weekly: check a sample of the stored data. Use restic check --read-data-subset=5% or borg check --verify-data (the Borg check reads everything, so it's slower).
Monthly: restore real files to a temporary folder and compare them, for example restic restore latest --target /tmp/restore-test --include /etc/nginx.
Every quarter: do a full restore onto a fresh test VPS by following the steps below, and time how long it takes.
If you'd rather not run this yourself, a Managed VPS lets UmmahHost's team handle server care for you. Ask them which backup options come with your plan.
Short answer: set up a clean server, reinstall your software, restore your files from the backup, import the databases, and check everything before you send traffic back. If you only need to undo a bad update, rolling back a snapshot is faster.
If the server still exists and you have a recent snapshot, restore it from your hosting control panel. Anything written after the snapshot was taken will be lost, so export recent orders or form entries first if you can.
Set up a fresh VPS, with the same OS version you backed up if possible.
Install your stack: web server, PHP or Node.js, database server and your backup tool.
Restore the files. First copy your repository password or Borg key from your password manager to the new server (with chmod 600), and set the same environment variables as in the backup script.
restic: restic restore latest --target /restore
Borg: borg extract ::ARCHIVE_NAME (run it from inside the folder you want to restore into; borg list shows the archive names)
rsync: rsync -aAX backup@backup-server:/backups/www/latest/ /var/www/
Import the databases: mysql < /restore/backup/mysql.sql or sudo -u postgres psql -f /restore/backup/postgres.sql postgres. This also restores stored procedures, triggers and events, because the dump included them.
Fix ownership and permissions, then restart your services.
Test before going live. Point your computer's hosts file at the new IP to preview the site, then check logins, forms and payments.
Update DNS if the server's IP address changed.
Restore into a separate /restore folder first, then copy files into place. That way you won't overwrite something you still need. Need just one file? restic's --include option restores a single path, and the official restic restore documentation covers it along with mounting a backup as a folder.
It depends on how much data you have, your network speed and how well you know the steps. A snapshot rollback can take minutes, while a full off-site restore of a large server can take hours. The only way to know your real number is to time a test restore. Write the steps down as a recovery runbook so anyone on your team can follow them under pressure.
That runbook is the heart of VPS disaster recovery. Plan it around two numbers:
RPO (Recovery Point Objective): how much data you can afford to lose. With nightly backups, you could lose up to a day of changes.
RTO (Recovery Time Objective): how long you can afford to be offline.
A busy online shop may need a database dump every few hours to keep its RPO acceptable.
In the early hours of 10 March 2021, a fire destroyed OVHcloud's SBG2 data centre in Strasbourg, France, and partly damaged the neighbouring SBG1 building (The Register). OVHcloud is one of Europe's largest hosting companies, and it told customers to activate their disaster recovery plans.
Customers who had copies somewhere else could rebuild. Many who didn't had nothing to rebuild from. OVH founder Octave Klaba said at the time that "some customers don't understand exactly what they bought" (DCD). OVH then promised to include backups by default, at no extra cost, in all its data centres.
Two years later, in March 2023, a French commercial court ordered OVH to pay one customer, Bluepad, about โฌ153,800 in damages for lost data. OVH reportedly planned to appeal.
Lesson: a backup stored in the same building as your server won't protect you if that building goes down.
On 31 January 2017, a GitLab engineer accidentally deleted data from the primary production database while fixing a replication problem. GitLab's own post-mortem estimates the incident affected about 5,000 projects, 5,000 comments and 700 new user accounts. Git repositories and wikis were not lost.
Then GitLab found that its regular backups hadn't been working, and the failure alerts hadn't reached anyone. It recovered from a copy an engineer had taken about six hours earlier for testing. Roughly six hours of database changes were lost, and the site was down for about 18 hours (InfoQ).
Lesson: backups need monitoring, failure alerts that reach a real person, and regular test restores.
Take a snapshot before every major update
Export your databases (with routines, triggers and events) before each backup run
Run automatic, encrypted, versioned backups every night
Keep repository passwords in a root-only file, never in commands or crontab
Prevent overlapping runs with flock
Keep at least one copy in a different data centre or region (3-2-1 rule; snapshots don't count)
Use an append-only or immutable copy as ransomware protection
Keep daily, weekly and monthly copies
Get an alert when a backup fails or doesn't run
Watch free space on the backup storage
Test a restore every month and time how long it takes
Store encryption keys and your runbook off the server
Do the snapshot and the off-site backup this week, then put a monthly test restore on your calendar. If you need a server that fits this plan, compare UmmahHost's VPSGuide, from BDIX VPS to Global VPS.
No. A plain rsync mirror keeps only one version and copies your mistakes and ransomware damage too. Add dated versions with --link-dest, or use a versioned tool like restic or Borg.
On separate storage in a different location, such as a second VPS, a storage server, or S3-compatible object storage in another data centre.
Nightly backups are enough for most sites. If your data changes all the time, as with an online shop or booking system, back up the database every few hours.
It's risky. Provider backups are a useful layer, but keep your own off-site copy too, so one company or one building isn't a single point of failure.
On some platforms, the server can slow down briefly while a snapshot is being made. Scheduling snapshots for low-traffic hours avoids most of that.
Author By
Anis Ur Rahman
Anis Ur Rahman writes domain and web hostingโrelated articles on behalf of Ummah Host. He works with domain name selection, web hosting, BDIX hosting, and website performance, and creates informational guides based on practical experience to help users make informed decisions. His writing focuses on providing reliable, easy-to-understand, and decision-supportive content.
15 Nov, 2026
We usually reply within seconds.
Support team online
Sales & technical support