Friday, August 16, 2013


From Commands I Always Forget...


rsync is a cool little app that has been around for ages, it allows you to copy stuff from one system to another using ssh.
rsync -avhPn --del -e 'ssh -p xxxxx' --exclude 'Dir_of_BigFiles' ~/Personal/ user@remote_host:Personal/
the -n means "dry-run" so it pretends to copy stuff but doesn't. -a means archive (most likely what you want for files like personal photos), -v for verbose incase something goes wrong, -h for human readable sizes, -P for progress, and --del for delete stuff on the destination that is not on the source (so be careful with paths, hence -n).
   Note: the --exclude directories are paths relative to the files being moved, not from where you execute the command.

I run this on my work laptop to sync the personal files (mostly pictures of my kid) from there to my home server.  My home server is allowing ssh incoming on a high port (to keep the script kiddies away) and I keep forgetting the syntax to rsync over ssh on a non standard port.  Oh, I also exclude the directory with big files (movies) since my bandwidth at home is kinda limited.

No comments:

Post a Comment