tips
45 tips Backup
One command, setting or habit at a time about Backup: what it does, the line to copy and a caveat or two.
rsync 13
-
Reads the list of files to transfer from a text file or from standard input.
rsync -a --files-from=list.txt /home/me/ backup:/backup/ -
Moves files that rsync overwrites or deletes into a separate folder instead of losing them.
rsync -a --delete --backup-dir=/backups/old-2026-12-01 /data/ /backups/current/ -
Skips every file that already exists on the receiving side, even if the source copy is newer.
rsync -av --ignore-existing photos/ nas:/photos/ -
Keeps partially transferred files after an interruption instead of deleting them.
rsync --partial --progress big-file.iso nas:/isos/ -
Caps how many files rsync may delete in one run, and exits with an error when the limit is hit.
rsync -av --delete --max-delete=50 /mnt/user/photos/ [email protected]:/mnt/user/backup/photos/ -
Keeps a compressed backup rsync-friendly, so a small change means a small transfer.
tar -cf - /mnt/user/appdata/app | gzip --rsyncable > /backup/app.tar.gz -
Lets rsync create every missing folder of the destination path, like mkdir -p.
rsync -a --mkpath photos/2026/ [email protected]:/mnt/user/backup/photos/2026/ -
Copies files to another machine with rsync and deletes each one once it safely arrived.
rsync -av --remove-source-files ~/Downloads/done/ [email protected]:/mnt/user/media/incoming/ -
Makes full daily backup folders where unchanged files are hard links, so they take almost no space.
rsync -a --link-dest=../2026-11-25 /src/ /backup/2026-11-26/ -
Shows a single progress line for the whole transfer instead of one per file.
rsync -ah --info=progress2 /source/ /destination/ -
Shows a single progress line for the whole copy instead of one per file.
rsync -a --info=progress2 ~/Videos/ /mnt/nas/Videos/ -
Prints what rsync would copy or delete, without touching any file.
rsync -ani --delete ~/Documents/ /mnt/backup/Documents/ -
With a slash on the source rsync copies the contents; without it, the folder itself.
rsync -a photos/ /backup/ # puts the contents straight in /backup/
Backup repositories 8
-
Show restic snapshots grouped by host, path or tag.
restic snapshots --group-by host,paths -
Searches the snapshots of a restic repository for files that match a pattern.
restic find "*.txt" -
Counts the data in a restic repository in four modes, from restore size to raw blobs.
restic stats -
Mounts a Borg repository or archive as a filesystem so you can copy files out.
borg mount /path/to/repo /mnt/borg -
Verifies a random or numbered slice of your restic repository by reading the actual data files.
restic -r /srv/restic-repo check --read-data-subset=10% -
Shows which files a restic backup would process, so you can test your excludes without making a snapshot.
restic -r /srv/restic-repo backup /mnt/user/appdata --dry-run -vv -
Makes restic skip any folder that contains a marker file you chose, such as .nobackup.
restic -r /srv/restic-repo backup /mnt/user/appdata --exclude-if-present .nobackup -
Keeps restic from crossing into other mounted filesystems when you back up a directory tree.
restic -r /srv/restic-repo backup --one-file-system /
Time Machine 8
-
Compares backup data with the checksums Time Machine recorded when it was written.
tmutil verifychecksums /path/to/backup-item -
Moves your apps, accounts and files from a Time Machine backup onto a Mac.
Applications > Utilities > Migration Assistant > transfer from a Mac, Time Machine, or startup disk -
Makes Time Machine back up daily, weekly or only when you ask.
System Settings > General > Time Machine > Options > Backup Frequency -
Encrypts your Time Machine disk so a lost drive doesn't expose your files.
System Settings > General > Time Machine > Add Backup Disk > Encrypt backups -
Checks that a Time Machine backup on a network disk is still in good shape.
Time Machine menu > hold Option > Verify Backups -
Lets a new or repaired Mac keep adding to its old Time Machine backup.
sudo tmutil inheritbackup "/Volumes/timemachine/Old MacBook.sparsebundle" -
Shows the date of your newest Time Machine backup from Terminal.
sudo tmutil latestbackup -
Starts a Time Machine backup from Terminal and waits until it has finished.
tmutil startbackup --auto --block
Updates and backups 4
-
Lists the files that were added, removed or changed between two restic snapshots.
restic -r sftp:[email protected]:/restic-repo snapshots -
Removes the stale lock that keeps a restic repository blocked after an interrupted run.
restic -r sftp:[email protected]:/restic-repo unlock -
Lists backup versions and files from the command line, and restores them to a folder you pick.
duplicati-cli find "file:///mnt/backup/duplicati" --passphrase="..." -
Explains that a Portainer backup is restored on the first-run setup page of a fresh, empty instance.
docker volume rm portainer_data
Backups and dumps 2
-
Adds stored procedures, functions and scheduled events to a mysqldump backup.
mysqldump --routines --events mydb > mydb.sql -
Copies the data files of a whole running PostgreSQL server into compressed tar files.
pg_basebackup -D backup -Ft -z -P
Files and media 2
-
Keeps the files a sync would overwrite or delete in a separate folder on the same remote.
rclone sync --interactive /mnt/user/appdata/<app> remote:current --backup-dir remote:old -
Makes tar backups that only contain the files that changed since the previous run.
tar -czf /backup/docs-0.tar.gz -g /backup/docs.snar /home/user/docs
Access and security 1
-
Saves the LUKS header and keyslots to a file, so a damaged header does not mean lost data.
sudo cryptsetup luksHeaderBackup /dev/sdb1 --header-backup-file /root/sdb1-header.img
Admin and checks 1
-
Verifies a PostgreSQL base backup against its manifest for missing, extra or damaged files.
pg_basebackup -h mydbserver -D /usr/local/pgsql/data
Apps and containers 1
-
Creates a partial backup first, then updates Home Assistant Core, from the ha command line.
ha core update --backup
Library and imports 1
-
Makes a backup of your Sonarr and Radarr settings and gets it off the server.
Linux and shell 1
-
Saves every overwritten file as a numbered copy, so you can always go back.
cp --backup=numbered nginx.conf /etc/nginx/nginx.conf
Settings and services 1
-
Finds and deletes old iPhone backups that take up space on your Mac.
System Settings > General > Storage > iOS Files
Updates and troubleshooting 1
-
A floor for your appdata backups, so an age rule can never delete the last good one.
ls -lt /mnt/user/backups | head
Windows 1
-
Shows what a robocopy mirror would copy and delete before it touches any file.
robocopy C:\Data D:\Backup /MIR /L
Nothing in this filter yet.