My rsync Command

Ok so I started out using rsync with the options ‘-a –progress –delete’ and I thought that was doin’ the job just fine. But recently I migrated our old 600mhz Dell Optiplex GX110 to a Sans Digital MobileNAS MN2L dual drive RAID NAS and the rsyncs weren’t going as planned.

Rsync Screenie

The rsync argument ‘-a’ preserves permissons, owner, groups, etc. (-a for archive) but I would run it repeatedly to get the latest changes and it would start copying the whole thing over again. After visiting the rsync man page I came up with a new set of arguments that seem to be working out great.

UPDATE: After much confusion I have come to the conclusion that when using rsync via cygwin over SMB shares for large file transfers, modification times are often slightly off, causing many files to be overwritten repeatedly. After trying a few options, I found that the argument --modify-window=10 can rectify this issue.

[sourcecode language=’bash’]rsync -rtmvh –modify-window=10 –stats –progress /path/to/source /path/to/destination/[/sourcecode]
Argument descriptions:

-r, –recursive recurse into directories

-t, –times preserve modification times

-m, –prune-empty-dirs prune empty directory chains from file-list

-v, –verbose increase verbosity

-h, –human-readable output numbers in a human-readable format

–modify-window=10 treat timestamps as equal if they differ by no more than 10 seconds

–stats give some file-transfer stats

–progress show progress during transfer

*Great for testing: -n, –dry-run perform a trial run with no changes made, just would-be transfer results

*Optional: –delete delete extraneous files from dest dir

For many more useful arguments visit the official rsync man page.

I wanted to log this before my .bash_history gets messed up again. 🙂

3 Replies to “My rsync Command”

  1. Excelent script

    The only thing is that –stats –progress –delete hast to be with –:
    rsync -rtmvh –stats –progress –delete /path/to/source/ /path/to/destination/

    Thanks 🙂

  2. Yeah I forgot that’s a common problem with the editor in WordPress, it turns double-slashes into one. 😐

    Thanks a lot, if you have other any improvements or caveats please contribute.

    * All right – I remembered to put the command in <code></code> tags.
    * I installed SyntaxHighlighter Plus and used ‘bash’ as the language but the command shows up funny 🙁
    It’s still an improvement I guess.

    Thanks, Sam

Leave a Reply

Your email address will not be published. Required fields are marked *