Karl-Philipp Richter
2014-Jun-16 12:29 UTC
Print files which would be transfered by rsync (when syncing two directories)
Hi together, after I read "very often" without even a tiny bit of a contradiction, I start to have the feeling I have a basic misunderstanding of rsync. Assume one want to get a list of files which would have been transfered by rsync if rsync was requested to sync directories X and Y and one does <code> X=`mktemp` echo "abc" > $X/1 echo "abc1" > $X/2 Y=`mktemp` echo "abc" > $Y/1 echo "abc2" > $Y/2 </code> then I'd expect rsync to update the file $Y/2 with the content of $X/2 and `rsync --dry-run --info=COPY -r -c $X $Y` should print $Y/2 (or $X/2, this isn't part of my problem), but it prints nothing. Further non-working solutions include: * `rsync --dry-run --info=COPY -r -c $X/ $Y/` # same as above with trailing slashes * `rsync -avun $SOURCE $TARGET` [http://unix.stackexchange.com/questions/57305/rsync-compare-directories] (printing both files or nothing (with and without trailing slashes)) * `rsync -rvnc --delete $X/ $Y/` [http://psung.blogspot.de/2008/06/comparing-directory-trees-with-diff-or.html] (basically the same as `avun`, but does the same) * `rsync -n $X $Y` [http://superuser.com/questions/576687/rsync-print-only-files-that-would-have-been-changed] which seems already false by intuition as rsync doesn't display separated file infos if not instructed to do so) Where is my misunderstanding and if there's none, how do I get rsync to print $X/2 (or $Y/2) in my example above? Any help is appreciated :) All the best, Kalle Richter -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 538 bytes Desc: OpenPGP digital signature URL: <http://lists.samba.org/pipermail/rsync/attachments/20140616/e2415bbf/attachment.pgp>
Heiko Schlittermann
2014-Jun-16 13:23 UTC
Print files which would be transfered by rsync (when syncing two directories)
Hi, Karl-Philipp Richter <krichter722 at aol.de> (Mo 16 Jun 2014 14:29:04 CEST):> Hi together, > after I read "very often" without even a tiny bit of a contradiction, I > start to have the feeling I have a basic misunderstanding of rsync. > > Assume one want to get a list of files which would have been transfered > by rsync if rsync was requested to sync directories X and Y and one does > <code> > X=`mktemp` > echo "abc" > $X/1 > echo "abc1" > $X/2 > Y=`mktemp` > echo "abc" > $Y/1 > echo "abc2" > $Y/2 > </code>You ment 'mkdir -d'> then I'd expect rsync to update the file $Y/2 with the content of $X/2 > and `rsync --dry-run --info=COPY -r -c $X $Y` should print $Y/2 (or > $X/2, this isn't part of my problem), but it prints nothing. Further > non-working solutions include: > * `rsync --dry-run --info=COPY -r -c $X/ $Y/` # same as above withThe info-Option my rsync doesn't have.> trailing slashes > * `rsync -avun $SOURCE $TARGET` > [http://unix.stackexchange.com/questions/57305/rsync-compare-directories] (printing > both files or nothing (with and without trailing slashes))$ rsync -avun $X $Y sending incremental file list tmp.VvH2oCg59K/ tmp.VvH2oCg59K/1 tmp.VvH2oCg59K/2> * `rsync -n $X $Y` > [http://superuser.com/questions/576687/rsync-print-only-files-that-would-have-been-changed] > which seems already false by intuition as rsync doesn't display > separated file infos if not instructed to do so)And $X and $Y are dirs, rsync won't recurse into dirs without using the proper options. [> Where is my misunderstanding and if there's none, how do I get rsync to > print $X/2 (or $Y/2) in my example above?That's what I use. The "killer option" is "-i" $ rsync -n -ia $X $Y cd+++++++++ tmp.VvH2oCg59K/>f+++++++++ tmp.VvH2oCg59K/1 >f+++++++++ tmp.VvH2oCg59K/2-- Heiko -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 847 bytes Desc: Digital signature URL: <http://lists.samba.org/pipermail/rsync/attachments/20140616/b4e89e9d/attachment.pgp>
Wayne Davison
2014-Jun-16 15:26 UTC
Print files which would be transfered by rsync (when syncing two directories)
On Mon, Jun 16, 2014 at 5:29 AM, Karl-Philipp Richter <krichter722 at aol.de> wrote:> <code> > X=`mktemp` > echo "abc" > $X/1 > echo "abc1" > $X/2 > Y=`mktemp` > echo "abc" > $Y/1 > echo "abc2" > $Y/2 > </code>I'll assume you meant to use -d on your mktemp commands (as another responder *almost* pointed out).> * `rsync --dry-run --info=COPY -r -c $X/ $Y/` # same as above with > trailing slashes >This is almost the right command, you're just asking for the wrong info. The trailing slashes are needed to properly tell rsync to just copy the contents of the one dir to another without copying the directory by name inside the transfer. If you had also asked for --info=NAME you'll have gotten the names of the transferred files. The COPY info is for "files copied locally on the receiving side", as in the case where you use something like --copy-dest=DIR and rsync makes a copy of a local file instead of transferring it from the sending side. As for what the -n option does, it just tell rsync not to do any work. Any output generated is only what you tell it to output, so -n is usually paired with -v (--verbose). ..wayne.. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20140616/98177881/attachment.html>