Ubuntu

Synchronize files with rsync

Installing rsync

sudo apt-get install rsync

Manual Syncing

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

or

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

-a
archive mode
-z
compress file data during the transfer
–progress
show progress during transfer
–size-only
skip files that match in size

Automatic Syncing

1. Create a bash script that contains the following:

#!/bin/bash
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
delete files from destination directory that no longer exist in local directory
–delay-updates
put all updated files into place at transfer’s end
–compress-level=NUM
explicitly set compression level, values: 0-9
–exclude-from=FILE
read exclude patterns from FILE

for more options type:

rsync -h