The situation is as follows:

  • Machine A has a file repository accessible via rsync
  • Machine B needs the above mentioned files with all permissions and ownerships intact (including groups etc)
  • Machine C has access to both A and B, but has a completely different set of users.

Normally, i would just rsync everything over, directly between A and B, but due to severely limited bandwidth at the moment, i need something different, as rsync times out after building the list of the 430 files (49Mb uncompressed... can be compressed down to ~7Mb).

What i've tried so far: rsync everything over from A to C, tar it, copy the tarball over, and then untar it, however, this messes up the ownership and/or the permissions.

To rsync it from A to C, i run this command:

rsync --numeric-ids --password-file=/root/rsync_pwd_file -oaPvu rsync://exsync@example.com/portal_2/ ./portal_2/

...and from the looks of things, they do end up on C with the correct ownerships/permissions/flags/everything (not 100% sure, though.. are there any more switches i can throw in there? did i miss something?)

copying the tarball over is simple enough (slow as a one-legged turtle due to the bandwidth, but it checksums out alright)

What i'm unsure of is the flags and switches for creating and extracting the tarball, so could someone please provide the full commands for creating a tarball from /root/portal_2 on machine C (with everything intact) and extracting the tarball into /var/ex/portal_2 on machine B? ?

Also, are there any other approaches worth mentioning that could allow me to perform this? I have root access to A and C, whereas i only have rsync access to B.

PS: I'm running rsync v2.6.9 on machine B, and unfortunately i do not have the oportunity to upgrade to v3


So, to answer the tar question:

cd /root; tar -jcv --numeric-owner -f portal_2.tar.bz2 portal_2


cd /var/ex; tar xf portal_2.tar.bz2
  • --numberic-owner made a whole lot of difference. Cheers! – Jarmund Nov 11 '12 at 0:15

I'm not quite sure if I read your question right. Can A talk to B directly? If so, simply use rsync -e 'ssh -oServerAliveInterval=30' to avoid rsync/ssh timing out.

If A cannot directly talk to B, I would try the following:

  • From C ssh to A with a reverse port forward to B (ssh -R2222:B:22 A)
  • On A rsync to localhost:2222 aka the port forward
  • Use rsync -e 'ssh -oServerAliveInterval=30' to avoid rsync/ssh timing out.

That way you sidestep both the users issue and work around the timeouts.

  • A can talk to B directly, but I do not have SSH access to A. Only rsync:// is available to me on A. – Jarmund Nov 10 '12 at 23:55
  • Oh that kinda ruins my solution :) Do the connections via C use ssh or also just rsync://? – Dennis Kaarsemaker Nov 11 '12 at 0:06
  • C is my private server, so "anything" goes. – Jarmund Nov 11 '12 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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