Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9
rsync copies only the changes since the last run, which makes it ideal for regular backups from your computer or server to a VPS. This guide works on Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9 and macOS (as the source).
1. Prepare the backup VPS
- Create a user for backups:
useradd -m backup. - On the source machine, create a key and copy it:
ssh-keygen -t ed25519 -f ~/.ssh/backup_keyandssh-copy-id -i ~/.ssh/backup_key.pub backup@VPS-IP. - Test:
ssh -i ~/.ssh/backup_key backup@VPS-IP.
2. Run a backup
rsync -az --delete -e "ssh -i ~/.ssh/backup_key" /home/me/Documents/ backup@VPS-IP:backups/documents/
Without --delete, files you delete locally stay in the backup. With it, the backup is an exact mirror, so a deleted file also disappears from the backup at the next run.
3. Keep daily versions (snapshots)
With --link-dest, each day gets its own folder, but unchanged files are stored only once (as hard links):
TODAY=$(date +%F) rsync -az --delete -e "ssh -i ~/.ssh/backup_key" \ --link-dest=../latest /home/me/Documents/ backup@VPS-IP:backups/$TODAY/ ssh -i ~/.ssh/backup_key backup@VPS-IP "ln -sfn $TODAY backups/latest"
Delete old day folders on the VPS from time to time, for example those older than 30 days.
4. Automate
# crontab -e 30 2 * * * /home/me/bin/backup.sh >> /home/me/backup.log 2>&1
5. Restore
rsync -az -e "ssh -i ~/.ssh/backup_key" backup@VPS-IP:backups/latest/ /home/me/Documents-restored/
Tip: Test a restore now and then. Keep at least one copy in a different location, and back up databases as dumps (mariadb-dump), not as raw files.