LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 10-30-2011, 09:24 AM   #1
jonmcc
LQ Newbie
 
Registered: Dec 2005
Distribution: Fedora Core 4
Posts: 7
Blog Entries: 1

Rep: Reputation: 2
rsync make parents on remote


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..

ssh <remote> mkdir -p /backup/var/spool/cron/crontabs
rsync -vauz /var/spool/cron/crontabs <remote>:/backup/home/var/spool/cron/.

Ideally, I'd like to be able to do this:

rsync -Mvauz /var/spool/cron/crontabs <remote>:/backup/home/var/spool/cron/.

...where M (make parents) is a new option that tells mkdir to do 'mkdir -p' on the remote target dir.

Maybe this is already possible, but I've some some googling & people end up doing it with a few commands.

(apologies if this is already answered in these forums already)
 
Old 10-31-2011, 10:46 AM   #2
daveginorge
Member
 
Registered: Oct 2006
Location: Porsgrunn, Norway
Distribution: CentOS 5 / 6 / 7
Posts: 107

Rep: Reputation: 16
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.
Hope this helps
 
Old 01-09-2012, 08:56 AM   #3
jonmcc
LQ Newbie
 
Registered: Dec 2005
Distribution: Fedora Core 4
Posts: 7

Original Poster
Blog Entries: 1

Rep: Reputation: 2
Thanks Dave.

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.

Last edited by jonmcc; 01-09-2012 at 08:57 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync - Remote to local gabriel01 Linux - Software 3 03-09-2011 08:40 AM
Trying to rsync from remote to local dooley28 Linux - Software 1 09-23-2010 01:03 AM
rsync over two remote hosts Meson Linux - General 5 01-12-2008 08:46 AM
Remote admin of parents linux w/ krfb pH* Linux - General 1 01-02-2005 08:05 AM
how do I make the children gone with the parents jpan Programming 6 09-19-2004 11:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration