02.07.2020
rsync
is a great tool for copying files, especially to/from remote locations, like ssh-servers. I use it almost daily for managing this website and also for backing up some personal files to a server so I have access to them from anywhere. For syncing different computers on the same wifi I recommend Syncthing.
I almost always use
rsync -avzhu --delete src dest
-a
archive mode: equivalent to -rlptgoD
, which basically means replicate everything as exactly as possible
-r
recurse into directories-l
recreate symlinks in the destination-p
preserve permissions in dest
-t
preserve modification times-g
preserve group-o
preserve owner-D
equivalent to --devices --specials
, which preserves device and special files-v
verbose output-z
compress the files during the transfer-h
output numbers in human-readable format-u
update: skip files that have a newer modification time at dest
--delete
delete extraneous files from dest
Sometimes I want to exclude a certain directory from being updated/deleted, so I use the --exclude dir
option as well.
I use a small wrapper script for deploying to the webserver and for my personal documents I’ve created two wrapper scripts, one for pulling and the other one for pushing.
If you want to give me some feedback or share your opinion, please contact me via email.
© Niklas Bühler, 2021 RSS / Contact me