Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'd like rsync to create the source dir structure on the remote, when I'm only synching a file in a sub-dir. At the moment it seems I need to do this in 2 commands, e.g..
If you drop the trailing /. it should work
rsync -vauz /var/spool/cron/crontabs <remote>:/backup/home/var/spool/cron
from the rsync man
Quote:
rsync -avz foo:src/bar /data/tmp
this would recursively transfer all files from the directory src/bar
on the machine foo into the /data/tmp/bar directory on the local machine.
The files are transferred in "archive" mode, which ensures that symbolic links,
devices, attributes, permissions, ownerships etc are preserved in the transfer.
Additionally, compression will be used to reduce the size of data portions of the transfer.
rsync -avz foo:src/bar/ /data/tmp
a trailing slash on the source changes this behavior to transfer all files
from the directory src/bar on the machine foo into the /data/tmp/.
A trailing / on a source name means "copy the contents of this directory".
Without a trailing slash it means "copy the directory".
This difference becomes particularly important when using the --delete option.
That'll work fine for the "bar" subdir (of src) to get synched under /data/tmp, so you'd end up with /data/tmp/bar. What I want is to end up with /data/tmp/src/bar
So, assuming I only have a /backup dir on the remote box and want the entire directory structure from the source to end up under this, I currently need to create them manually first, e.g...
ssh <remote> mkdir -p /backup/var/spool/cron/crontabs
rsync -vauz /var/spool/cron/crontabs <remote>:/backup/var/spool/cron/.
It would be nice if rsync had an option to do this for you automatically.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.