Back up and synchronise with rsync
Copy only what changed, locally or over SSH.
- Dry run first (writes nothing):
rsync -aHAXv --dry-run --delete /home/moi/Documents/ /media/disque/Documents/
- If the result is what you expect, run again without --dry-run:
rsync -aHAXv --delete /home/moi/Documents/ /media/disque/Documents/
- To a remote server over SSH:
rsync -aHAXvz -e ssh /home/moi/Documents/ utilisateur@serveur:/sauvegardes/documents/
- The trailing "/" on the source matters: with it, the folder's contents are copied; without it, the folder itself.
- Automate with cron and keep several versions with the --backup-dir option.
⚠️ --delete removes from the destination what no longer exists in the source: always test with --dry-run.