Why is a second machine the right backup target?
Because a copy on the same box shares its fate. The second NVMe drive in your machine protects against one drive failing, but not against a mistaken rm, ransomware with root, a broken file system or a reinstall. A backup must live on hardware that the source cannot erase. The cheapest way here is a second machine in another city: an E1 for small sites, an S3 with 2x 1 TB NVMe for mid-size data, or a D20 with 4x 4 TB NVMe for large estates. Uploads into the backup box are inbound traffic, which is free.
Should the backup push or pull?
Pull. If the production machine pushes backups, it needs write access to the backup target, so anyone who takes over production can delete your backups too. When the backup machine pulls, production holds no credentials for it. The backup box logs in to production with a key that can only run rsync in read mode.
On the production machine, add the backup key to a dedicated account with a forced command. The rrsync helper shipped with rsync restricts the key to one folder, read-only:
command="/usr/bin/rrsync -ro /srv",restrict ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHb... vault-pull
On Debian and Ubuntu the helper may sit at /usr/share/doc/rsync/scripts/rrsync in older releases; copy it to /usr/local/bin and make it executable if /usr/bin/rrsync is missing.
How do snapshots with --link-dest work?
Each run creates a new dated folder. Files that did not change since the last snapshot are not copied again; rsync creates a hard link to the existing file instead. Every snapshot looks like a complete copy and can be browsed or restored directly, but unchanged data is stored only once.
#!/bin/sh
# /usr/local/sbin/pull-web01.sh on the backup machine
set -eu
BASE=/backup/web01
NEW=$BASE/$(date +%Y-%m-%d_%H%M)
LAST=$(ls -1d $BASE/20* 2>/dev/null | tail -n 1 || true)
rsync -aH --numeric-ids --delete \
${LAST:+--link-dest="$LAST"} \
-e 'ssh -i /root/.ssh/vault_ed25519 -o IdentitiesOnly=yes' \
pull@203.0.113.25:/ "$NEW/"
echo "$NEW done"
Because rrsync pins the source to /srv on production, the remote path / means that folder. The first run copies everything; later runs only move the day's changes.
What about databases?
Dump them before the pull. Copying a running database's files produces a backup that may not start. Schedule a dump on production a little before the pull window:
mysqldump --single-transaction --routines --events --all-databases | zstd -q -T0 > /srv/dumps/mysql-$(date +%a).sql.zst sudo -u postgres pg_dumpall | zstd -q -T0 > /srv/dumps/pg-$(date +%a).sql.zst
Naming dumps by weekday keeps seven rotating files on production, while the snapshots on the backup box keep as many days as you like.
How long should I keep snapshots?
| Keep | How |
|---|---|
| Every day for two weeks | Delete daily folders older than 14 days |
| One per week for two months | Keep the Sunday folder, delete the rest past 14 days |
| One per month for a year | Keep the first folder of each month |
Deleting an old snapshot is safe with hard links: data still used by a newer snapshot stays on disk until the last link disappears. Check real usage with du -sh /backup/web01/*; the first folder shows the full size and later ones only their unique data.
How do I schedule it?
Use a systemd timer on the backup machine so runs are logged in the journal and missed runs after a reboot are caught up:
# /etc/systemd/system/pull-web01.timer [Timer] OnCalendar=*-*-* 03:20 RandomizedDelaySec=15m Persistent=true [Install] WantedBy=timers.target
Pair it with a service unit that runs the script, then systemctl enable --now pull-web01.timer. A plain cron line works too; see Set up a cron job.
How do I know backups actually work?
Restore something every month. Pick a random file and a database dump, copy them to a scratch folder or a spare machine, and open them. Watch the job's exit status with systemctl status pull-web01.service, and alert yourself when the newest snapshot is older than a day. A backup system that is never tested tends to fail on the one day it is needed.
Machines That Make Good Backup Targets
| Server | Processor | Cores / threads | Memory | Storage | Network | Per month | Smallest order |
|---|---|---|---|---|---|---|---|
| E1 | Intel Xeon E3-1240 v3 | 4 / 8 | 16 GB DDR3 | 2x 240 GB SSD | 2x 1 Gbps | $30.52 | $91.56 (3 months) |
| S3 | Intel Xeon E-2356G | 6 / 12 | 64 GB DDR4 | 2x 1 TB NVMe | 2x 10 Gbps | $80.38 | $80.38 (1 month) |
| D20 | 2x Intel Xeon Gold 6336Y | 48 / 96 | 256 GB DDR4 | 4x 4 TB NVMe | 2x 25 Gbps | $990.36 | $990.36 (1 month) |
Keep Reading
Rsync command examples
Twelve rsync patterns for daily admin work: local copies, checksums, partial resumes, size limits, backups of replaced files and safe deletes.
OpenRsync over SSH
Copy and mirror folders between machines with rsync over SSH: trailing slashes, dry runs, custom ports, sudo on the far side and bandwidth caps.
OpenStorage servers
From 8 TB mirrors to a six-drive NVMe array of more than 90 TB raw, with ZFS or mdadm laid out by you.
OpenOutbound traffic allowance
How the 15 TB monthly egress allowance works, what it means per day and per second, and why inbound data costs nothing.
OpenFAQ
Quick Answers
It helps against a single drive failure only. Real backups belong on another machine, ideally in another city.
Unchanged files are hard-linked to the previous snapshot, so each day stores only new and changed data.
Pull from the backup machine, so a compromised production server holds no credentials to delete backups.
Data arriving at the backup box is inbound and free. Production sends it out, which counts against production's monthly allowance.
Not safely. Dump the database first with its own tools, then let rsync copy the dump.