Skip to content
CryptoDedicated
Menu

How do I back up a dedicated server with restic?

How to back up a dedicated server with restic to a second machine over SFTP, including live databases, a nightly timer and a restore drill.

Updated , by the CryptoDedicated team, 5 min read

Quick answer

How do I back up a dedicated server with restic?

Install restic, store a repository password in a root-only file, run restic init against an SFTP target on another machine, then back up /etc, /home, /root and data folders nightly, piping database dumps in with --stdin. Prune with restic forget and test a restore monthly. CryptoDedicated machines from $83.69 can serve as source or target, paid in Monero.

In brief
  • Off the machine: RAID 1 mirrors mistakes, so the repository must live on other hardware, ideally another city.
  • SFTP backend: restic only needs SSH access to the target, no agent and no special server software.
  • Encrypted at the source: the target stores ciphertext; losing the password loses the backups.
  • Databases via stdin: mysqldump | restic backup --stdin gives a consistent dump without a temporary file.
  • Restore drill: a monthly restic restore of one folder proves the chain works end to end.

What should be in the backup, and what should be left out?

Back up what cannot be rebuilt from packages: configuration, data and dumps; skip caches and kernel file systems.

restic include and exclude list for a Debian or Ubuntu dedicated server running a web stack and a database
Path or sourceBack up?Reason
/etcYesEvery service configuration, SSH host keys, firewall rules
/home and /rootYesUser files, scripts, SSH authorized_keys
/var/www, /srv, /optYesSites and applications
Database dump via --stdinYesConsistent copy of live MySQL or PostgreSQL data
/var/lib/mysql or /var/lib/postgresqlNoRaw files of a running database are not consistent; use the dump
/proc, /sys, /dev, /run, /tmpNoVirtual or temporary file systems
/var/cache, node_modules, .cacheNoRebuilt automatically

How do I set up restic from scratch?

  1. Prepare the target

    On the second machine, create a user such as backup with a folder /srv/restic and add the source server's SSH public key to its authorized_keys.

  2. Install restic on the source

    apt install restic; if the distribution package is old, use the static binary from the official GitHub releases instead.

  3. Write the password file

    Generate a long random password into /root/.restic-password with mode 600 and keep a copy outside both servers.

  4. Initialise the repository

    Run restic init with -r sftp:backup@TARGET:/srv/restic; this creates the encrypted structure.

  5. Run the first backup

    Back up the include list with an exclude file, then pipe each database dump in with --stdin-filename.

  6. Schedule it

    A systemd service plus a daily timer runs the same commands each night and logs to the journal.

  7. Prune and verify

    restic forget with keep rules and --prune once a week, restic check once a month, and a test restore.

First run on the source server (TARGET is the backup machine)
apt install -y restic
restic version
head -c 48 /dev/urandom | base64 > /root/.restic-password && chmod 600 /root/.restic-password
export RESTIC_REPOSITORY=sftp:backup@TARGET:/srv/restic
export RESTIC_PASSWORD_FILE=/root/.restic-password

restic init
printf '/var/cache\n**/node_modules\n**/.cache\n' > /root/restic-excludes
restic backup /etc /home /root /var/www /srv /opt --exclude-file=/root/restic-excludes --tag files
mysqldump --single-transaction --all-databases | restic backup --stdin --stdin-filename mysql-all.sql --tag db

restic snapshots
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
restic check
restic restore latest --tag files --target /tmp/restore-test --include /etc/nginx
/etc/systemd/system/restic-backup.service and .timer
# restic-backup.service
[Unit]
Description=Nightly restic backup

[Service]
Type=oneshot
Environment=RESTIC_REPOSITORY=sftp:backup@TARGET:/srv/restic
Environment=RESTIC_PASSWORD_FILE=/root/.restic-password
ExecStart=/usr/bin/restic backup /etc /home /root /var/www /srv /opt --exclude-file=/root/restic-excludes --tag files
ExecStart=/bin/sh -c 'mysqldump --single-transaction --all-databases | /usr/bin/restic backup --stdin --stdin-filename mysql-all.sql --tag db'

# restic-backup.timer
[Timer]
OnCalendar=*-*-* 03:30
RandomizedDelaySec=15m
Persistent=true

[Install]
WantedBy=timers.target

# enable: systemctl daemon-reload && systemctl enable --now restic-backup.timer

Where should the restic repository live?

On different hardware, preferably in a different city, reached over SSH with a key that can do nothing but write backups. Two CryptoDedicated machines, one in Amsterdam and one in Zurich, can back each other up across two countries at the same price.

Other good targets: a home NAS with SFTP, or any S3-compatible bucket, which restic reaches with -r s3:.... A target on the same machine protects against deleted files only, not against a failed server or a reinstall that wipes both drives. To harden the target, restrict the backup user in its authorized_keys with restrict and an internal-sftp ForceCommand, so a stolen source cannot open a shell there.

How does restic compare with the backup option CryptoDedicated sells?

The paid option is the hands-off choice; restic is the flexible, encrypted, long-retention choice. Many customers run both.

  • CryptoDedicated's option: Extra IPv4 $3.40 a month each (up to 8), daily backups kept 7 days for 12% of the machine price, assisted migration $59.00 once.
  • restic: free software, retention as long as the target has space, encrypted with a key only the customer holds, restorable file by file.

The option is ordered as an add-on on the checkout; the terms are on extra IPv4, backups and migration. RAID 1 is no substitute for either, as the RAID 1 status guide explains.

What does a monthly restore drill look like?

Pick one folder and one database snapshot, restore them to a scratch path, and compare. restic restore latest --target /tmp/restore-test --include /etc/nginx brings back a folder; restic dump latest mysql-all.sql | head shows the dump is readable.

Write the time it took next to the date. If the whole server had to come back, the order is: new machine or reinstall, the same packages, restic restore of /etc and data, then the database import, the same sequence as a VPS to dedicated migration. According to CryptoDedicated's survey of 30 October 2026, 34 of the 48 providers read sold dedicated servers; whichever host is chosen, the restore plan stays the customer's job.

Frequently asked questions

Does restic need software on the backup target?

No, only an SSH account with SFTP. restic also supports its own rest-server and S3-compatible storage.

How big will the repository get?

The first snapshot is roughly the size of the data after compression; later ones add only changed chunks thanks to deduplication.

Can two servers share one repository?

Yes. Each snapshot records its host name, and identical files across servers are stored once.

What if the restic password is lost?

The repository cannot be decrypted by anyone. Keep the password in a password manager and on paper, never only on the server.

Is the backup add-on encrypted like restic?

The add-on is run by CryptoDedicated and kept 7 days. For backups only the customer can read, encrypt them with restic before they leave the machine.

Verdict
  • restic over SFTP to a second machine is the strongest free backup for a dedicated server: encrypted, deduplicated, scriptable.
  • Add CryptoDedicated's daily backup option if a provider-side copy with zero setup is worth 12% of the machine price.
  • A backup that was never restored is a guess: run the monthly drill.
Sources (4)
  1. Preparing a new repository (SFTP) — restic documentation (read 2026-11-30)
  2. Backing up (reading data from stdin) — restic documentation (read 2026-11-30)
  3. Removing backup snapshots — restic documentation (read 2026-11-30)
  4. systemd.timer(5) — systemd (read 2026-11-30)

A second server to hold the backups

Ryzen 9700X, 2 × 1 TB NVMe in RAID 1, any of 4 cities: $154.54 per 30 days.

Read next

$154.54 Ryzen 9700X, per 30 days

Order