I was trying to process a bunch of folders to sync them to another drive and ran across an error I haven’t seen before. Normally I do this sync via a mounted file system, but this time I tried to do it over ssh: find . -type f -atime -1 -exec rsync -aP {} 10.0.0.11:/Volumes/Drive5/{} \; bash: -c: line 0: syntax error near unexpected token `(' bash: -c: line 0: `rsync --server -logDtpre.iLsfx --log-format=X --partial . /Volumes/Drive5/./Taxes (2012)/W2 (2012).pdf' rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1] If I mount Drive5 and run the same command, it works fine. Put "/Volumes/Drive5/{}” in quotes doesn’t help. Ideas? -- Why can't you be in a good mood? How hard is it to decide to be in a good mood and be in a good mood once in a while?"
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 If you want find to generate your list use --files-from: find . -type f -atime -1 -print0 | rsync -aP --files-from=- --from0 . 10.0.0.11:/Volumes/Drive5/ On 08/17/2015 02:13 AM, @lbutlr wrote:> I was trying to process a bunch of folders to sync them to another > drive and ran across an error I haven’t seen before. Normally I do > this sync via a mounted file system, but this time I tried to do it > over ssh: > > find . -type f -atime -1 -exec rsync -aP {} > 10.0.0.11:/Volumes/Drive5/{} \; bash: -c: line 0: syntax error near > unexpected token `(' bash: -c: line 0: `rsync --server > -logDtpre.iLsfx --log-format=X --partial . /Volumes/Drive5/./Taxes > (2012)/W2 (2012).pdf' rsync: connection unexpectedly closed (0 > bytes received so far) [sender] rsync error: error in rsync > protocol data stream (code 12) at io.c(226) [sender=3.1.1] > > If I mount Drive5 and run the same command, it works fine. > > Put "/Volumes/Drive5/{}” in quotes doesn’t help. > > Ideas? >- -- ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._., - -*~ Kevin Korb Phone: (407) 252-6853 Systems Administrator Internet: FutureQuest, Inc. Kevin at FutureQuest.net (work) Orlando, Florida kmk at sanitarium.net (personal) Web page: http://www.sanitarium.net/ PGP public key available on web site. ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._., - -*~ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlXRsdYACgkQVKC1jlbQAQemkwCgmpxsHaVMdzvS4WI8HGzhyPaM IUwAnjqSGzNXNFOQlGUVm+lHktgxVBzL =OV94 -----END PGP SIGNATURE-----
On Aug 17, 2015, at 4:05 AM, Kevin Korb <kmk at sanitarium.net> wrote:> If you want find to generate your list use --files-from: > > find . -type f -atime -1 -print0 | rsync -aP --files-from=- --from0 . > 10.0.0.11:/Volumes/Drive5/This works: find . -type f -atime -1 -exec rsync -aP {} /Drive5/{} This fails if there are ()’s in the file name. find . -type f -atime -1 -exec rsync -aP {} 10.0.0.11:/Drive5/{} -- I WILL NOT ENCOURAGE OTHERS TO FLY Bart chalkboard Ep. 7F03
I haven't used rsync with networks, but I do use bash a lot. First, let me state the obvious. It looks like your code is executing rsync in a bash one liner once for each file that find returns. That's not cool! And it's almost definitely not what you wanted to do. Among other things, that means that bash is seeing all those embedded blanks and the parentheses in your file names and getting upset because blanks delimit arguments and parentheses are used for a number of syntactically meaningful things. So, at a minimum, you need to escape/quote *both* of your file references {} - not just the one. But the real issue is that you should probably let find put all the resulting file names into a file or pipe and send that to rsync once using something like --files-from=FILE read list of source-file names from FILE where you should be able to use "-" as the file name so it uses the output of the find command as input to rsync. Once you get that sorted, any remaining errors should be a lot easier to fix. Joe On 08/17/2015 02:13 AM, @lbutlr wrote:> I was trying to process a bunch of folders to sync them to another drive and ran across an error I haven’t seen before. Normally I do this sync via a mounted file system, but this time I tried to do it over ssh: > > find . -type f -atime -1 -exec rsync -aP {} 10.0.0.11:/Volumes/Drive5/{} \; > bash: -c: line 0: syntax error near unexpected token `(' > bash: -c: line 0: `rsync --server -logDtpre.iLsfx --log-format=X --partial . /Volumes/Drive5/./Taxes (2012)/W2 (2012).pdf' > rsync: connection unexpectedly closed (0 bytes received so far) [sender] > rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1] > > If I mount Drive5 and run the same command, it works fine. > > Put "/Volumes/Drive5/{}” in quotes doesn’t help. > > Ideas? >
On Aug 17, 2015, at 3:06 PM, Joe <josephj at main.nc.us> wrote:> First, let me state the obvious. It looks like your code is executing rsync in a bash one liner once for each file that find returns. That's not cool! And it's almost definitely not what you wanted to do.It is perfect;y acceptable and definitely ‘cool’. This gives me stats on each file, which is what I want.> Among other things, that means that bash is seeing all those embedded blanks and the parentheses in your file names and getting upset because blanks delimit arguments and parentheses are used for a number of syntactically meaningful things.That does not explain why bash is perfectly happy with the command line if it is a locally mounted disk (the same disk, in fact). Despite the error, this is not a bash problem.> So, at a minimum, you need to escape/quote *both* of your file references {} - not just the one.Find’s {} is escaped, just doesn’t seem to be escaped properly via ssh/rysnc. As I said, this works: find . -type f -atime -1 -exec rsync -aP {} /Drive5/{} This fails if there are ()’s in the file name. find . -type f -atime -1 -exec rsync -aP {} 10.0.0.11:/Drive5/{}> But the real issue is that you should probably let find put all the resulting file names into a file or pipe and send that to rsync once using something like > --files-from=FILE read list of source-file names from FILE > where you should be able to use "-" as the file name so it uses the output of the find command as input to rsync.Hmm. Maybe. I’ll play with that. -- Why live in the world when you can live in your head? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20150817/51401b7b/attachment.html>
On Sun, Aug 16, 2015 at 11:13 PM, @lbutlr <kremels at kreme.com> wrote:> find . -type f -atime -1 -exec rsync -aP {} 10.0.0.11:/Volumes/Drive5/{} > \; >The use of "{}" on the receiving (remote) side is superfluous -- just specifying a destination dir (your .../Drive5/ path) is enough for rsync to use the same name as the source file on the destination. For those instances where you want/need to specify a remote filename, see the --protect-args (-s) option (which you can make the default via "export RSYNC_PROTECT_ARGS=1", and which will eventually become the default in the future). Finally, the suggestion to use --files-from=- is a good one, which fixes all quoting issues even on the local side. ..wayne.. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20150817/41715230/attachment.html>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 It is true that you don't need the {} in the remote arg but due to the syntax you probably want --relative instead. On 08/17/2015 07:03 PM, Wayne Davison wrote:> > On Sun, Aug 16, 2015 at 11:13 PM, @lbutlr <kremels at kreme.com > <mailto:kremels at kreme.com>> wrote: > > find . -type f -atime -1 -exec rsync -aP {} > 10.0.0.11:/Volumes/Drive5/{} \; > > > The use of "{}" on the receiving (remote) side is superfluous -- > just specifying a destination dir (your .../Drive5/ path) is enough > for rsync to use the same name as the source file on the > destination. For those instances where you want/need to specify a > remote filename, see the --protect-args (-s) option (which you can > make the default via "export RSYNC_PROTECT_ARGS=1", and which will > eventually become the default in the future). Finally, the > suggestion to use --files-from=- is a good one, which fixes all > quoting issues even on the local side. > > ..wayne.. > >- -- ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._., - -*~ Kevin Korb Phone: (407) 252-6853 Systems Administrator Internet: FutureQuest, Inc. Kevin at FutureQuest.net (work) Orlando, Florida kmk at sanitarium.net (personal) Web page: http://www.sanitarium.net/ PGP public key available on web site. ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._., - -*~ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlXSaQ0ACgkQVKC1jlbQAQdMQQCeLRiV9+d6Pc6ZmBzc0VNQOX3O b/MAoMy8+TtJJfai0i9SLDsvPc+ki0lc =NRoX -----END PGP SIGNATURE-----
> On Aug 17, 2015, at 5:03 PM, Wayne Davison <wayned at samba.org> wrote: > > The use of "{}" on the receiving (remote) side is superfluous -- just specifying a destination dir (your .../Drive5/ path) is enough for rsync to use the same name as the source file on the destination.That is the case if {} contains simply a file name, but is not the case when {} contains a relative path as well. /path/to/root/path/to/file cd /path/to/root find . -type f -exec rsync {} /path/to/dest/{} => /path/to/dest/path/to/file find . -type f -exec rsync {} /path/to/dest/ => /path/to/dest/file> For those instances where you want/need to specify a remote filename, see the --protect-args (-s) option (which you can make the default via "export RSYNC_PROTECT_ARGS=1", and which will eventually become the default in the future). Finally, the suggestion to use --files-from=- is a good one, which fixes all quoting issues even on the local side.10.0.0.11:/Drive5/\"{}\” Works. -- "Any man who says he can see through women is really missing a lot." - Groucho Marx -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20150818/231b14c9/attachment.html>