Synchronize files with rsync

Installing rsync

sudo apt-get install rsync

Manual Syncing

rsync -az --progress --size-only /home/username/dir1/* /home/username/destination/


rsync -az --progress --size-only /home/username/dir1/* my.server.com:/home/username/destination/

archive mode
compress file data during the transfer
show progress during transfer
skip files that match in size

Automatic Syncing

1. Create a bash script that contains the following:

rsync -az --progress --size-only /home/username/dir1/* /home/username/destination/
2. Make script executable:
chmod a+x /path/to/script/syncmydata.bash

3. Schedule it to run every hour
3.1 Open your crontab: crontab -e
3.2 Append this: 0 * * * * /path/to/script/syncmydata.bash

Extra Useful Options

delete files from destination directory that no longer exist in local directory
put all updated files into place at transfer’s end
explicitly set compression level, values: 0-9
read exclude patterns from FILE

for more options type:

rsync -h