Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've learned that with the -i option, I can get rsync to list all the changes it makes. I've been using it along with the -n or --dry-run options so that I can always learn about all expected changes prior to actually executing them.

I've been using rsync mainly to sync my home directories on my two computers, both of which are connected to a network. Often times I need to move just a small number of relatively small files. If this is the case, rsync spends more time going through all the files it's going to exclude from the transfer rather than actually transferring the actual changed files.

Now if I follow this procedure where I first do a dry run and list all the changes, and then actually proceed, the longest part of calculating the files that are to be excluded from the transfer gets done two times.

I'd like to cut it to just one. Is there a way to feed the itemized list of changes created by the dry run back to rsync so that the live run is faster or do something to that effect?

share|improve this question
2  
You may want to try out Unison which, if I understand correctly, will do this in one run. –  N.N. Nov 29 '12 at 17:03
1  
I second N.N.: this sounds like exactly what Unison was designed for. Only use rsync if you're always synchronizing in the same direction, otherwise you will lose work because one day you'll make a mistake deciding which way to synchronize. Unison figures this out automatically and tells you if (and only if) there is a conflict (different changes to the same file on the two computers). –  Gilles Nov 29 '12 at 23:03
1  
Sounds like a use case of rdup or maybe even git-annex. –  sr_ Nov 30 '12 at 9:13
    
Have you tried speeding up the rsync by using the -W flag? From man rsync: -W, --whole-file copy files whole (w/o delta-xfer algorithm) –  laebshade Mar 30 '13 at 4:28
add comment

1 Answer 1

from the man page of rsync:

-F same as --filter='dir-merge /.rsync-filter' repeated: --filter='- .rsync-filter'

        --exclude=PATTERN       exclude files matching PATTERN
        --exclude-from=FILE     read exclude patterns from FILE
        --include=PATTERN       don't exclude files matching PATTERN
        --include-from=FILE     read include patterns from FILE
        --files-from=FILE       read list of source-file names from FILE

so run rsync -i first and output it to a file and use --files-from option or you can use find utility for finding the last modified file and then rsync them. see http://serverfault.com/questions/115945/synchronizing-very-large-folder-structures

share|improve this answer
    
look at csync2 and lsyncd if you want some more customization see axivo.com/community/threads/… –  harish.venkat Nov 29 '12 at 17:20
    
Thanks. The problem with this approach is that the output of -i doesn't just list the files that are to be transferred/synched, it also lists deletions. If you're running with the backup and backup-dir options, those deletions change to mv's. I suppose I could grep out just actual transfers and then handle deletes separately... I was kind of hoping for a more elegant solution that wouldn't involve me having to write my own wrapper scripts. –  ThorX89 Nov 29 '12 at 17:58
    
you can use excludes with the “perishable” modifier.Recent versions of rsync allow filter rules to be flagged with a perishable modifier. The rsync man page describes this modifier as follows.A p indicates that a rule is perishable, meaning that it is ignored in directories that are being deleted. see blog.mudflatsoftware.com/blog/2012/10/31/… –  harish.venkat Nov 29 '12 at 19:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.