Skip to content

rsync

This post intends for periodically syncing files onto a NAS.

Ignore Files

List all ignored files in an ignore file:

.rsyncignore
.*
go
codeql
kind
llvm-project-*

Then specify rsync command with --exclude-from=.rsyncignore option

Final Example

rsync -avz -e ssh --delete --exclude-from=.rsyncignore . nas:/volume1/Documents/ziyue/server-backup

Add Crontab

To run the command periodically, we setup a cron job using crontab -e, add following command

0 * * * * rsync -avz -e ssh --delete --exclude-from=.rsyncignore . nas:/volume1/Documents/ziyue/server-backup

The first 0 means that this cron job will be executed at the beginning of every hour.