http://rsync.samba.org Remote synchronization Smart synchronization / excellent mirroring programTODO Data security > Backups > rsync
Intro
rsync is still my current king, but still not quite what I wanted. It's not smart enough to see simple folder renames or moves.
Basic rsync folder synchronization
The first time I played with rsync it took me some time to figure out how to get it to work! To make the destination the same as the source, do:
rsync -av --delete --progress //path/to/source// //path/to/dest//-a --archive archive mode, equivalent to -rlptgoD
Yeah, that's a lot of options all rolled together. =/
-v --verbose increase verbosity
--delete delete files that don't exist on the sending side
This one was very confusing. It means "Delete files on the destination which don't exist on the source" or I suppose another phrase would be "replicate deletions".
--progress show progress
--bwlimit=KBPS Bandwidth limit -- fuzzy, most effective with large files.
-n --dry-run show what would have been transferred
--exclude exclude/omit files.
You can use this parameter multiple times.
(not working) Folder synchronization when the destination has limited free space
Seems impossible.
nice -n 10 rsync --temp-dir=/mnt/sda9/rsync-temp/ --bwlimit=10000 --stats --sparse --delete-before --archive --hard-links --verbose --progress /mnt/source/ /mnt/dest/Is --keep-dirlinks useful?
Why the fuck isn't there just one --make-the-destination-the-fucking-same parameter?
rsync folder synchronization over SSH
What was recommended to me, but remains untested:
rsync -av -e ssh <username>@<target>:/path/to/source/ //path/to/dest//
- username = the user that exists on that remote machine
- target = either the IP or the web address of the remote machine.
- If the remote machine has an IP address that changes, use no-ip.com or dyndns.org or some other similar service.
rsync folder synchronization over FTP
Rsync over FTP isn't possible. Why? I have no clue.. they decided to leave that part out..
Try lufs for mounting an FTP site, or LFTP and mirroring.
rsync - Detect renamed files and handle by renaming instead of delete/re-send
At first, [1] rsync v3 was supposed include filename charset-conversion support and renamed-file detection! But some time afterwards they removed any mention of it. There is also no mention of renaming in any changelog or news item. They simply purged this announcement entirely. =(
- bug 2294 Detect renamed files and handle by renaming instead of delete/re-send
Apparently this isn't actually possible. --fuzzy doesn't do it.
[not working] Merging directories
NOTE! THIS DOES NOT SEEM TRUSTWORTHY!
It initially tested ok, but now it seems to destroy files!!
Finally, a decent replacement for mv!
rsync -av --progress --remove-source-files //source/* /dest//I edit my .bashrc with this:
rsyncmv() { rsync -av --progress --remove-source-files "$1" "$2" ; }
so I can now do:
rsyncmv //path/to/source/* /path/to/dest//
possibly: rsync -a SOURCE/ DEST/ --remove-sent-files --ignore-existing --whole-file
rsync troubleshooting
permissions spam
To remove them, instead of the usual -a use -rlt
rsync cannot overwrite files
sending incremental file list test.html rsync: rename "/mnt/mnt/httpdocs/.test.html.gpPO1R" -> "test.html": Operation not permitted (1)This is because rsync incorrectly thinks that my local login would have to be the same uid/gid as the remote setup! WHOA.
No chmod voodoo is necessary. What you actually need to do is implement a workaround for rsync to pre-delete the files it would prefer to overwrite. Then the sync will be copying "new files" which will work just fine.
The solution is noted in secure synchronization. Gods that was annoying to implement.
This is probably a one-liner change in the rsync source for "don't be such a smartass".
rsync and cp cannot send large files over samba: File too large (27)
See samba (TO PORT)
rsync: read errors mapping "/path/to/file.ext": Input/output error (5)
# rsync -av . /dest/ sending incremental file list path/to/file.ext rsync: read errors mapping "/path/to/file.ext": Input/output error (5) WARNING: path/to/file.ext failed verification -- update discarded (will try again). path/to/file.ext rsync: read errors mapping "/path/to/file.ext": Input/output error (5) ERROR: path/to/file.ext failed verification -- update discarded. sent 3578910 bytes received 2128 bytes 246968.14 bytes/sec total size is 79431643878 speedup is 22181.18 rsync error: some files could not be transferred (code 23) at main.c(1031) [sender=3.0.2]Manually copying the file to a temporary location also gave an error:
cp: reading `/path/to/file.ext': Input/output errorBut the file copied, and it was complete and proper.
So I copied the file from that temporary location to the destination and it gave no error!
Then rsync worked without error!
I have no idea what was going on here..