# How do I back up a VPS?

> How to back up a VPS in 7 steps with restic: dump databases, create an encrypted repository off the server, schedule it and test a restore.

- URL: https://saltvps.com/guides/how-to-back-up-a-vps/
- Last updated: 2026-11-16
- Publisher: SaltVPS (https://saltvps.com)

**Quick answer — How do I back up a VPS?**

To back up a VPS, dump each database to a file, then use restic to send encrypted, versioned snapshots of your data and configs to another machine, schedule it daily and test a restore. No **SaltVPS** plan includes backups, so a second server in another of the 6 cities, or any SFTP or S3 storage, holds the copies.

**In brief**

- **Tool**: restic, free, encrypted, deduplicated and versioned.
- **Where**: off the server: another VPS over SFTP, or S3-compatible storage.
- **What**: databases as dump files, then `/etc`, web roots, app data and home folders.
- **When**: daily, with old snapshots thinned by `restic forget --prune`.
- **Proof**: a backup counts only after a restore works.

## How do you back up a VPS with restic?

**Run as root. The repository here is a second server reached over SFTP with an SSH key.**

1. **Install restic** — Run apt install restic on Debian and Ubuntu, or dnf install restic from EPEL on AlmaLinux and Rocky Linux.
2. **Set up SSH to the backup host** — Create a key with ssh-keygen -t ed25519, add its public half to the backup user on the second server and test ssh backup@backup-host.
3. **Store the repository password** — Put a long random password in /root/.restic-pass and run chmod 600 /root/.restic-pass. Keep a copy elsewhere: without it, the backups cannot be read.
4. **Create the repository** — Run restic -r sftp:backup@backup-host:/srv/restic --password-file /root/.restic-pass init.
5. **Dump databases first** — Run mysqldump --single-transaction --all-databases > /var/backups/mysql.sql, or pg_dumpall for PostgreSQL, so a consistent copy sits on disk.
6. **Run the backup** — Run restic -r sftp:backup@backup-host:/srv/restic --password-file /root/.restic-pass backup /etc /var/www /var/backups /home.
7. **Test a restore** — Run the same -r and --password-file options with restore latest --target /root/restore-test, then compare a few files.

## Should you use restic or rsync to back up a VPS?

**rsync copies; restic keeps history. Many setups use rsync for speed and restic for safety.**

*restic and rsync compared as tools to back up a VPS*

| Feature | restic | rsync |
| --- | --- | --- |
| Keeps old versions | Yes, as snapshots | No, unless you add dated folders or hard links |
| Encryption at rest | Yes, always | No |
| Deduplication | Yes | No |
| Targets | Local disk, SFTP, S3-compatible and others | Local disk or SSH |
| Restore | restic restore or restic mount | Copy files back |
| Best for | Daily versioned backups | Mirrors and server-to-server moves |

## How do you schedule and thin out backups?

**Put the dump and backup commands in a small script and run it from cron each night.** For example, in root's crontab (`crontab -e`): `30 3 * * * /root/backup.sh`. In the script, after the backup, add retention:

- `restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune`
- `restic check` once a week, to verify the repository

Set `RESTIC_REPOSITORY` and `RESTIC_PASSWORD_FILE` at the top of the script so each command stays short.

## Where should VPS backups live?

**Anywhere but the server itself, ideally in another data centre.** A disk failure, a bad command or a reinstall would take an on-server copy with it. SaltVPS checked its plan list on 16 November 2026: none of the 7 plans includes backups, and a [reinstall](https://saltvps.com/help/reboot-reinstall-delete/ "How do I reboot, reinstall or delete a SaltVPS server?") erases the disk.

One simple setup: a production server in Frankfurt and a Grain (40 GB NVMe) in Amsterdam as the restic target, at $2.25 a month on 12 months. Plans with larger disks are on the [pricing page](https://saltvps.com/pricing/ "How much does a SaltVPS server cost per month?"). Restrict the backup user to SFTP and its own folder.

## What is the best way to back up a VPS in 2026?

**Follow the 3-2-1 idea: three copies, two kinds of storage, one far away.** For a single server, that means the live data, a restic repository on another server, and a second repository or an occasional download at home. restic can copy snapshots between repositories with `restic copy`.

Backups also make moving easy: the [migration guide](https://saltvps.com/guides/how-to-migrate-a-website-to-a-new-vps/ "How do I migrate a website to a new VPS?") restores a site on new hardware. Pair backups with the rest of the [Linux VPS security guide](https://saltvps.com/guides/how-to-secure-a-linux-vps/ "How do I secure a Linux VPS?").

## VPS backup questions

### Does SaltVPS take snapshots of my server?

No. No plan includes backups or snapshots, so keep your own copies off the server.

### What should I back up on a VPS?

Database dumps, /etc, web roots, app data folders, Docker volumes and home folders. The operating system itself can be reinstalled.

### How do I back up Docker volumes?

Stop or pause the app, or dump its database, then back up the volume folder under /var/lib/docker/volumes with restic.

### Can I back up a VPS to my home computer?

Yes. Run restic or rsync from home over SSH, or download a restic repository regularly.

### How often should I test a restore?

After the first backup, then every few months or after any change to the backup script.

**Verdict**

- **Back up a VPS with daily restic snapshots stored on another machine.**
- **Dump databases first and test a restore**; untested backups are only hope.

## Sources

1. [restic documentation](https://restic.readthedocs.io/en/stable/) — restic project (2026-11-16)
2. [rsync(1) manual](https://download.samba.org/pub/rsync/rsync.1) — rsync project (2026-11-16)
3. [mysqldump reference](https://dev.mysql.com/doc/refman/8.4/en/mysqldump.html) — Oracle MySQL (2026-11-16)

**A second server for your backups** Grain gives 40 GB NVMe in any of the 6 cities, a good off-site restic target. [Order Grain for 12 months](https://saltvps.com/app/checkout/?plan=grain&term=12m&from=guides-how-to-back-up-a-vps&lang=en) · [All guides](https://saltvps.com/guides/ "Which VPS guides and Linux tutorials does SaltVPS publish?")

---

SaltVPS: SaltVPS sells Linux KVM VPS in New York, Dallas, Los Angeles, London, Amsterdam and Frankfurt, paid in crypto with no ID document. Seven plans from 2 to 32 GB of RAM cost the same in all six cities, and on the 12-month term each is priced at least 25% under a named comparable plan of a no-KYC crypto host, read on 16 November 2026. The operator is DomaineGoat LLC, Panama.
