Quick answer: rsync copies directories over SSH and, after the first run, transfers only what changed. A single command like rsync -avz /var/www/ user@storage:/srv/backups/www/ is already a working backup; add --delete, excludes and a dated snapshot layout as you grow.
Overview
rsync is the workhorse of Linux backups: preinstalled almost everywhere, bandwidth-efficient and scriptable. This guide covers the flags that matter, what to include and exclude, and the hard-link trick that turns a plain mirror into space-efficient point-in-time snapshots.
Before you start
- SSH access to a backup target, ideally a Storage VPS with key authentication set up.
- A list of directories that actually hold state: typically
/etc,/var/www,/home, database dumps. - rsync on both sides:
apt install rsync(Debian/Ubuntu) ordnf install rsync(AlmaLinux/Rocky).
Step-by-step guide
- Start with a dry run to see what would be copied:
rsync -avzn /var/www/ [email protected]:/srv/backups/www/ - Run the real transfer (drop the
n):rsync -avz /var/www/ [email protected]:/srv/backups/www/-akeeps permissions/owners/timestamps,-vshows progress,-zcompresses in transit. - Exclude junk that wastes space:
rsync -avz --exclude 'cache/' --exclude '*.tmp' /var/www/ [email protected]:/srv/backups/www/ - Mirror deletions only when you also keep snapshots —
--deletemakes the copy exact but removes your safety net on its own. - Snapshots with hard links — unchanged files cost no extra space:
TODAY=$(date +%F) rsync -avz --delete --link-dest=/srv/backups/www-latest \ /var/www/ [email protected]:/srv/backups/www-$TODAY/ ssh [email protected] "ln -sfn /srv/backups/www-$TODAY /srv/backups/www-latest"
Common issues
- Trailing slash confusion:
/var/www/copies the contents,/var/wwwcopies the directory itself into the target — pick one convention and stick to it. - Databases copied live: dump them first with
mysqldump/pg_dump; raw datadir copies are corrupt more often than not. - Root-owned files skipped: run the job as a user that can read everything you back up, or use sudo carefully.
When to contact support
rsync itself is standard Linux tooling; if transfers to your Cloud2Y Storage VPS stall or the network drops mid-sync repeatedly, open a ticket with timestamps and both server IPs.
Frequently asked questions
What do the rsync -avz flags actually do?
The -a flag preserves permissions, owners and timestamps while recursing; -v prints what is transferred; -z compresses data in transit, which speeds up transfers over the internet.
Should I use the --delete option with rsync?
Only when you also keep dated snapshots. With --delete the target mirrors every deletion, so on its own it happily propagates yesterday's mistake to your only backup copy.
How do rsync hard-link snapshots save space?
With --link-dest, unchanged files in a new dated directory are hard links to the previous snapshot, so each night costs only the size of changed files while looking like a full copy.
Related articles
- How to configure backups to a Storage VPS
- How to automate backups with cron
- Backup retention policy explained
- How to encrypt backups
Need reliable space for your backups? Order a Storage VPS at Cloud2Y →
