Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [SOLVED] Rsync refuses to create folder.

    I'm using Ubuntu 10.04 32 bit but this should apply to linux, in general.

    I am having a curious problem with an rsync script. Although I could opt to just back up my complete home folder, I choose to be selective and only backup what I would actually need if a hard drive disaster occurred. I am having difficulty backing up properly when I back up files in a subfolder but no files from the base folder the subfolder is under. Rsync refuses to create the base folder in the backup target partition and therefore will not create the subfolder and files either.

    Here's an example. It's my ".config" folder. There are a number of subfolders but I am only interested in backing up the "transmission" subfolder. My line for that in my script is this:

    rsync -arv /home/trapper/.config/transmission/ /media/RSYNC-Backup/trapper/.config/transmission/
    When I run it I get this error message:

    rsync: mkdir "/media/RSYNC-Backup/trapper/.config/transmission" failed: No such file or directory (2)
    rsync error: error in file IO (code 11) at main.c(595) [Receiver=3.0.7]
    rsync: connection unexpectedly closed (9 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(601) [sender=3.0.7]
    However, this works and creates the .mozilla folder and it's entire contents, including subfolders & all subfolder files, at the backup target.

    rsync -arv /home/trapper/.mozilla/ /media/RSYNC-Backup/trapper/.mozilla/
    Just to test, I added this to my script just prior to the transmission backup line:

    if [ ! -d /media/RSYNC-Backup/trapper/.config ]
    mkdir /media/RSYNC-Backup/trapper/.config
    The function above created the .config folder at the target and then the transmission folder backed up properly.

    I obviously have something wrong and am confused over the fact that rsync refuses to automagically create a ,config base folder for me. What do I not know that I should know?

  2. #2
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Boston, MA
    I believe you want the --relative flag.

    rsync -arvR /home/trapper/.config/transmission/ /media/RSYNC-Backup/trapper/
    man rsync
    -R, --relative
        Use relative paths. This means that the full path names specified on the
        command line are sent to the server rather than just the last parts of the
        filenames. This is particularly useful when you want to send several different
        directories at the same time.
        For example, if you used the command
         rsync foo/bar/foo.c remote:/tmp/
        then this would create a file called foo.c in /tmp/ on the remote machine. 
        If instead you used
         rsync -R foo/bar/foo.c remote:/tmp/
        then a file called /tmp/foo/bar/foo.c would be created on the remote machine.
        The full path name is preserved.

  3. #3
    Quote Originally Posted by reed9 View Post
    I believe you want the --relative flag.
    rsync -arvR /home/trapper/.config/transmission/ /media/RSYNC-Backup/trapper/
    Well, this is what I want and not what I want.

    This produces a /home/trapper/.config/transmission folder under /media/RSYNC-Backup/trapper

    What I was actually looking for was a .config/transmission folder under /media/RSYNC-Backup/trapper.

    However, all this you wrote also created a brain flash and an understanding why the .config folder is not created under /media/RSYNC-Backup/trapper

    I am probably better off if I adjust the rest of my script to use the --relative flag and simply back up to /media/RSYNC-Backup/. That will give me /media/RSYNC-Backup/home/trapper/"Everything I am backing up in my script"

    I can deal with that and will do it that way. Thanks for your assistance. I appreciate it.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts