Updated 30 October 2026
A VPS comes without backups: you manage it, so you also decide what gets saved and where. The simplest solid setup is restic: it encrypts your files, only uploads what changed, and keeps for example 7 daily, 4 weekly and 6 monthly snapshots. Store them somewhere other than the VPS itself, such as another server over SFTP or S3-compatible object storage. Below is a setup you can copy in about 20 minutes.
Checked on 29 October 2026 against the restic documentation (restic.readthedocs.io). Commands are for Ubuntu 24.04 and Debian 12/13; on Rocky Linux and AlmaLinux, restic comes from the EPEL repository (dnf install epel-release first).
1. Install restic and make a password file
apt update && apt install -y restic
mkdir -p /root/.restic && chmod 700 /root/.restic
openssl rand -base64 32 > /root/.restic/password && chmod 600 /root/.restic/password
2. Choose where the backups go
Option A: another server over SFTP. Any Linux machine or storage service with SSH access works. Make an SSH key for root on the VPS (ssh-keygen -t ed25519), add the public key on the backup server, and check that ssh user@backup-host logs in without a password. Then:
export RESTIC_REPOSITORY="sftp:user@backup-host:/srv/restic-myvps"
export RESTIC_PASSWORD_FILE=/root/.restic/password
restic init
Option B: S3-compatible object storage. Put the access key in the environment and use the provider's endpoint:
export AWS_ACCESS_KEY_ID=your-key
export AWS_SECRET_ACCESS_KEY=your-secret
export RESTIC_REPOSITORY="s3:https://your-endpoint/your-bucket/myvps"
export RESTIC_PASSWORD_FILE=/root/.restic/password
restic init
Put the export lines in /root/.restic/env (chmod 600), so the script below can read them.
3. Decide what to back up
- Your own data and config:
/etc,/home,/root,/srv,/optand/var/wwwif you use them. - Databases: don't copy the raw files of a running database. Dump them first, for example
mysqldump --all-databases --single-transaction > /root/db.sqlorpg_dumpall -U postgres > /root/db.sql, and back up the dump. - Not needed: the operating system itself,
/proc,/sys, caches andnode_modulesfolders. You can reinstall those.
4. A backup script and a daily timer
Save this as /usr/local/sbin/backup.sh and run chmod 700 on it:
#!/bin/sh
set -e
. /root/.restic/env
# mysqldump --all-databases --single-transaction > /root/db.sql # remove the # if you run MySQL/MariaDB
restic backup /etc /home /root /srv /opt --exclude-caches --exclude node_modules
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
Run it once by hand (/usr/local/sbin/backup.sh) and check the output. Then let systemd run it every night. /etc/systemd/system/backup.service:
[Unit]
Description=restic backup
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/backup.sh
/etc/systemd/system/backup.timer:
[Unit]
Description=Nightly restic backup
[Timer]
OnCalendar=*-*-* 03:30
RandomizedDelaySec=15m
Persistent=true
[Install]
WantedBy=timers.target
systemctl daemon-reload && systemctl enable --now backup.timer
systemctl list-timers backup.timer
--prune actually frees the space of snapshots that forget removed. Pruning locks the repository for a while, which is why it runs right after the backup.
5. Check and restore (do this once now)
. /root/.restic/env
restic snapshots # list all snapshots
restic check # check the repository is healthy
restic restore latest --target /tmp/restore-test --include /etc/hostname
cat /tmp/restore-test/etc/hostname
If you get your file back, your backups work. Practise this before you need it; a full restore to a fresh VPS is the same command without --include.
Prefer not to manage backups?
Game servers at ServerSpark get an encrypted nightly backup at a separate location, plus backup slots you control in SparkPanel. A VPS doesn't, because you have full root access and we don't look inside it. VPS S costs €7.99 per month paid per quarter (€8.29 monthly billing); see VPS hosting and first steps on a new VPS.
Frequently asked questions
Does a ServerSpark VPS include backups? No. A VPS is self-managed. Make your own backups to another location, for example with restic to another server over SFTP or to S3-compatible storage.
How do I back up a VPS automatically? Put restic backup and restic forget --prune in a script and run it every night with a systemd timer (OnCalendar=*-*-* 03:30, Persistent=true).
Can I store the backups on the same VPS? You can, but it doesn't protect you: if the server is lost, damaged or hacked, the backups go with it. Always keep a copy somewhere else.
What happens if I lose my restic password? Then the backups can't be decrypted. The restic documentation says losing the password means the data is irrecoverably lost, so keep a copy in a password manager.
How do I back up a MySQL or PostgreSQL database? Dump it first with mysqldump --single-transaction or pg_dumpall and back up the dump file, instead of copying the database files while it is running.