[SOLVED] rsync having trouble creating directories
SlackwareThis Forum is for the discussion of Slackware Linux.
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.
where foo is a valid user on the remote host with write permissions in the "workstations" directory (if it's the same user on the local host you don't need to specify it).
note that the source directory ends with a slash and is backupped in the remote one with the same name but the destination ends without a slash.
That's the odd thing. Yes, it's the same user on local as remote. And the user has the id_rsa.pub public key set. Note that in my OP the remote mkdir works OK, w/o my having to enter a password, `ssh bu6500.mydom.org mkdir -p /mnt/OHPRSbackup/Acronis/workstations`. But, trying your suggestion gives the same error:
Code:
$ rsync -rtva --delete --partial /mnt/localBackup/Acronis/workstations/ bu6500.mydom.org:/mnt/OHPRSbackup/Acronis/workstations
sending incremental file list
rsync: mkdir "/mnt/OHPRSbackup/Acronis/workstations" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(657) [Receiver=3.1.2]
No, the directory on the target machine does not exist. I'm expecting rsync to create directories that don't exist. It does work that way if doing local rsync's. I can have a completely empty target directory and `rsync -r` creates directories and copies files.
I don't get it. I'd hate to have to anticipate what directories and subdirectories have to pre-exist on the target.
after more experimentation ...
OK, so maybe at least the specified target directory has to exist? I.e. /mnt/OHPRS/backup/Acronis/workstations. rsync will then create subdirectories. When I created this directory on the target host (as the same user), then ran rsync, it started working.
Last edited by mfoley; 08-14-2017 at 08:02 PM.
Reason: after more experimentation
rsync will likely create any directories that it is syncing, but it likely needs the target directory to exist before it can start syncing. Just like how you need to have a folder created before you can mount a drive to it.
Granted, this is coming from someone who has basically no rsync experience, but I do know from using a lot of other programs over the years that you likely need the target directory to exist before running the command. After that, rsync should create any subdirectories from the remote source it is syncing.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
It does not create the directory on the target if you end your source with a backslash.
So if you have this on the source:
Code:
/s/1/file1
/s/1/file2
/s/1/file3
and this on the destination:
Code:
/d/1/
This command will run fine:
Code:
rsync -a /s/1/ /d/1/
But if your destination is:
Code:
/d/
The rsync will not create /d/1/ for you running:
Code:
rsync -a /s/1/ /d/1/
But, if you run this command:
Code:
rsync -a /s/1 /d/
it will create /d/1/ for you
The mistake you make is that you refer to a directory in the destination which does not exist yet. Rsync does not create directories which are specified in the destination path. However, you can force the creation of the directory by omitting the last slash in the source path and omitting the lowest level directory in the destination path.
jlinkels: Thanks for that. I see that the target directory specified in the rsync command needs to exist, then it can create sub-directies. I've made a note of this in my backup script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.