How to Back Up a VPS: Files, Databases and Off-Server Copies
A VPS gives you full control — and full responsibility for your data. Here is what to back up, how to automate it with a few commands, where to store the copies and how to make sure you can actually restore them.

To back up a VPS, copy three things off the server on a schedule: your website and application files, your database dumps and your configuration. Store the copies somewhere other than the VPS itself, encrypt them, keep several versions and test a restore from time to time. A backup that lives on the same server is not a backup.
This guide explains what to include, shows simple commands for Ubuntu or Debian, and covers automation, storage and restore tests.
What to back up
| What | Typical location | How |
|---|---|---|
| Website and app files | /var/www, /home, /srv | Archive or sync the folders |
| Databases | MySQL / MariaDB, PostgreSQL | Dump to a file first, then copy the dump |
| Configuration | /etc (web server, PHP, cron, firewall) | Archive the relevant folders |
| SSL certificates | /etc/letsencrypt | Include in the configuration backup |
| Email (if hosted) | Mail directories | Archive or sync |
Step by step: a simple daily backup
- Connect to the server — log in over SSH (see how to connect to a VPS via SSH).
- Dump the database — for MySQL/MariaDB:
mysqldump --single-transaction --all-databases | gzip > /root/backup/db-$(date +%F).sql.gz. - Archive files and config —
tar -czf /root/backup/files-$(date +%F).tar.gz /var/www /etc. - Copy off the server — for example
rsync -az /root/backup/ user@backup-host:/backups/myvps/, or use restic or BorgBackup for encrypted, versioned backups. - Automate it — put the commands in a script and run it every night with cron (
crontab -e). - Clean up — delete local dumps older than a few days so the disk does not fill up.
Where to store backups: the 3-2-1 rule
- 3 copies of your data — the live server plus two backups.
- 2 different storage types — for example a second server and object storage.
- 1 copy off-site — in another data centre or with another provider.
Use a separate account or credentials for the backup storage, so an attacker who gets into the VPS cannot delete the backups too.
How often and how long to keep them
- Daily for active sites, shops and anything with user data.
- Before every big change — updates, migrations or new plugins.
- Keep several versions — for example 7 daily, 4 weekly and a few monthly copies. A problem is not always noticed the same day.
Test a restore
A backup is only useful if it restores. A few times a year, restore the files and database to a test VPS and check that the site works. Note how long it takes — that is your real recovery time.
Backups as part of security
Backups are your last line of defence after a breach, a broken update or an accidental delete. Combine them with the rest of the VPS security checklist, and if you run WordPress, back up both the files and the database described in how to install WordPress on a VPS.
A VPS you control with mistREG
mistREG runs KVM VPS servers in the EU on NVMe SSD and AMD EPYC with full root access, so you can use any backup tool you like. See the VPS plans, browse our services or ask us on Telegram at @mistnetwork.


