LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-14-2017, 11:54 AM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Rep: Reputation: 177Reputation: 177
rsync having trouble creating directories


I seems to be having rsync issues lately ... I have the following:
Code:
$ rsync -rtv --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]
It seems that rsync cannot create the target directory path "/mnt/OHPRSbackup/Acronis/workstations", even though that user can create the path:
Code:
$ ssh bu6500.mydom.org mkdir -p /mnt/OHPRSbackup/Acronis/workstations

$ ssh bu6500.mydom.org ls -l /mnt/OHPRSbackup/Acronis
total 4
drwxr-xr-x 2 ohprs ohprs 4096 Aug 14 12:50 workstations
What am I doing wrong that rsync cannot create this directory?
 
Old 08-14-2017, 12:26 PM   #2
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,098

Rep: Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174
you have to use rsync via ssh adding the option "-e ssh".
 
Old 08-14-2017, 04:17 PM   #3
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by ponce View Post
you have to use rsync via ssh adding the option "-e ssh".
Sorry I don't see where I'd use that and the man page isn't enlightening me. Can you give me an example?

I tried the following and it doesn't work:
Code:
rsync -rtv --bwlimit=400m --delete --partial -e ssh /mnt/localBackup/Acronis/workstations/ bu6500.ohprs.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]

Last edited by mfoley; 08-14-2017 at 04:20 PM.
 
Old 08-14-2017, 04:26 PM   #4
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,098

Rep: Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174
Code:
rsync -avP --delete-after -e ssh /mnt/localBackup/Acronis/workstations/ foo@bu6500.ohprs.org:/mnt/OHPRSbackup/Acronis/workstations
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.

Last edited by ponce; 08-14-2017 at 04:28 PM.
 
Old 08-14-2017, 07:55 PM   #5
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
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
 
Old 08-14-2017, 09:12 PM   #6
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
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.
 
Old 08-14-2017, 09:31 PM   #7
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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

Last edited by jlinkels; 08-15-2017 at 02:14 PM.
 
2 members found this post helpful.
Old 08-15-2017, 10:53 AM   #8
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
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.
 
  


Reply

Tags
create, directory, fails, rsync



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you rsync 2 source directories into 2 target directories? anon091 Linux - Server 7 01-21-2016 10:43 AM
Merge directories with rsync xeon123 Linux - General 6 05-07-2015 07:38 AM
rsync not writing to existing directories sigint-ninja Linux - Newbie 10 06-10-2014 03:46 PM
rsync to check two directories...? resetreset Linux - Software 3 01-26-2011 03:53 AM
Rsync Command Skips Directories? carlosinfl Linux - General 1 12-10-2008 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:57 AM.

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