Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Help for a rsync error

  1. #1

    Default Help for a rsync error

    When I run the executable script

    # Script "backup.file.sh"
    #!/bin/sh # starts
    #
    # A shell script to backup an updated "a.file" from the
    # /home/user/project directory on the hard disk to the
    # /project directory on a flash drive as an exact
    # "a.file" copy.
    #
    # The updated "a.file" will then be backed up to
    #
    # another /project directory on a second flash drive,
    # to a /project directory on an external hard disk, and last
    # to a /project directory on a Windows Vista NTFS hard disk.
    #
    # rsync [options] from local SOURCE ...to... local DESTINATION
    #
    # [options are] progress, archive, verbose, preserve Hard links
    #
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1 /media/usb 1/project # the first backup operation for the "a.file"
    #
    # reminder chmod 755 backup.file.sh [convert to executable]
    # reminder [run] ./backup.file.sh
    #

    I receive the following error message:

    sending incremental file list
    rsync: link_stat "/media/usb" failed: No such file or directory (2)
    rsync: mkdir "/home/stephen/1/project" failed: No such file or directory (2)
    rsync error: error in file IO (code 11) at main.c(576) [receiver=3.0.4]
    rsync: connection unexpectedly closed (9 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(632) [sender=3.0.4]

    I ran the df command and the filesystem "/dev/sdc1" is mounted on "/media/usb 1". When I ran the mount command it writes onscreen

    /dev/sdc1 on /media/usb 1 type vfat (rw,nosuid,nodev,shortname=lower,flush,utf8,uid=1000)

    The flash drive "usb 1" also has a /project directory. However, an error occurs that I have tried hard to solve.

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    16,107

    Default Re: Help for a rsync error

    First. The shebang line
    Code:
    #!/bin/sh
    should be the very first line in a script or it will not be seen. But this will not be your problem.

    Second. When you realy have white space in the directory name where your device is mounted ( usb 1 ) you should understand that white space is also a seperator in shell commands, so the command
    Code:
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1 /media/usb 1/project # the first backup operation for the "a.file"
    has two fiields down there '/media/usb' and '1/project'. This is probably not what you want. So escape that white space by e.g.
    Code:
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1 /media/usb\ 1/project # the first backup operation for the "a.file"
    or
    Code:
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1 "/media/usb 1/project" # the first backup operation for the "a.file"
    Henk van Velden

  3. #3

    Default Re: Help for a rsync error

    Thank you very much for your kind assistance.

    For The Code changed to and ran as

    #!/bin/sh
    #
    # The shell script "backup.file.sh" is for backing up
    # an updated "a.file" from the
    # "/home/user/project" directory on a Linux hard disk
    # to an existing "/project" directory on a
    # First flash drive; to an existing
    # "/project" directory on a SECOND flash drive;
    # to an existing
    # "/project" directory on a Maxtor 3200 external HD;
    # and last to an also existing
    # "/project" directory on a Windows Vista NTFS HD
    #
    # rsync [options] from local SOURCE ...to... local DESTINATION
    #
    # [ the options are progress, archive, verbose, preserve Hard links ]
    #
    # a reminder chmod 755 backup.file.sh [convert to executable]
    # a reminder [run] ./backup.file.sh
    #
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1/media/usb 1/project
    #
    # < the prior blank space inserted was removed >

    this error message arises

    sending incremental file list
    rsync: change_dir "/dev/sdc1/media" failed: Not a directory (20)
    rsync: change_dir#3 "/home/stephen/usb" failed: No such file or directory (2)
    rsync error: errors selecting input/output files, dirs (code 3) at main.c(614) [receiver=3.0.4]
    rsync: connection unexpectedly closed (9 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(632) [sender=3.0.4]


    For the alternate Code ran as

    #!/bin/sh
    #
    # < the other comments have been omitted here for the sake of space >
    #
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1 "/media/usb 1/project"
    #
    # < /media/usb 1/project appears all between the parentheses after a blank space >

    this error message arises

    sending incremental file list
    rsync: mkdir "/media/usb 1/project" failed: No such file or directory (2)
    rsync error: error in file IO (code 11) at main.c(576) [receiver=3.0.4]
    rsync: connection unexpectedly closed (9 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(632) [sender=3.0.4]

    Do you have any idea what might be happening?

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    16,107

    Default Re: Help for a rsync error

    At least the error message is now about a directory you name, not about something else.

    I have no time atm to digg into rsync man page, but the error says that it can not make the directory "/media/usb 1/project". This could be because "/media/usb 1" is not writable by the user doing this. Check with
    Code:
    ls -l "/media/usb 1"
    and may be also check
    Code:
    ls -l /media
    What would make things using the CLI much easier is refraining from having white space in directory/file names. Can you make it just usb1 instead of "usb 1"?

    And I also would prefer it when you put computer text (like your script and the error messages) within CODE tags. Makes reading computer text much easier. (Select the text and use the # button above).
    Henk van Velden

  5. #5

    Default Re: Help for a rsync error

    For the lines changed to and ran as

    Code:
    #!/sbin/sh
    #
    # < the prior comments in the shell script are omitted here for the sake of space >
    #
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1/media/USB_1/project
    #
    # < the storage device was renamed as USB_1 and >
    # < the prior blank space inserted was removed >
    this error message arises now

    Code:
    sending incremental file list
    
    rsync: ERROR: cannot stat destination "/dev/sdc1/media/USB_1/project": Not a directory (20)
    rsync error: errors selecting input/output files, dirs (code 3) at main.c(554) [receiver=3.0.4]
    rsync: connection unexpectedly closed (9 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(632) [sender=3.0.4]

    For the lines changed to and ran as

    Code:
    #!/sbin/sh
    #
    # < the prior comments in the shell script are omitted here for the sake of space >
    #
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1 "/media/USB_1/project" 
    #
    # < the storage device was renamed as USB_1 and >
    # < /media/USB_1/project appears all between the parentheses after a blank space >
    this error message arises now

    Code:
    sending incremental file list
    rsync: chgrp "/media/USB_1/project/a.file" failed: Operation not permitted (1)
    skipping non-regular file "sdc1"
    
    sent 79 bytes  received 15 bytes  188.00 bytes/sec
    total size is 135018  speedup is 1436.36
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1040) [sender=3.0.4]

    The output for ls -l /media is

    Code:
    total 80
    drwxrwxrwx  1 root    root 12288 2009-04-25 13:39 disk
    drwxrwxrwx  1 root    root  4096 2009-04-25 07:25 Maxtor_3200
    drwxr-xr-x  6 stephen root 32768 1969-12-31 19:00 USB_1
    drwxr-xr-x 12 stephen root 32768 1969-12-31 19:00 USB_2

    The output for ls -l "/media/disk" is

    Code:
    total 7119313
    drwxrwxrwx 1 root root       4096 2009-02-13 08:55 project
    
    < NOT part of the actual Code:
      the other directories and files on the Windows Vista NTFS HD are omitted here for the sake of space >

    The output for ls -l "/media/Maxtor_3200" is

    Code:
    total 12
    drwxrwxrwx 1 root root 4096 2009-03-06 06:16 project
    
    < NOT part of the actual Code:
      the storage device was renamed as Maxtor_3200 removing the prior blank space inserted and
      the other directories and files on the external HD are omitted here for the sake of space >

    The output for ls -l "/media/USB_1"
    is

    Code:
    total 2016
    drwxr-xr-x 2 stephen   root  32768 2009-04-25 20:44 project
    
    < NOT part of the actual Code:
      the storage device was renamed as USB_1 removing the prior blank space inserted and
      the other directories and files on the First flash drive are omiited here for the sake of space >

    The output for ls -l "/media/USB_2"
    is

    Code:
    total 19808
    drwxr-xr-x 4 stephen root    32768 2009-04-02 05:42 project
    
    < NOT part of the actual Code:
      the storage device was renamed as USB_2 removing the prior blank space inserted and
      the other directories and files on the Second flash drive are omiited here for the sake of space >
    I do not know if the rw (read|write) permissions are affecting the "rsync" commands. Thanks once again for your help and advice.

  6. #6
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    16,107

    Default Re: Help for a rsync error

    You gave a lot of versions. I will stick to the first one:
    Code:
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1/media/USB_1/project
    In your first post there were two fields "/dev/sdc1" and "/media/USB 1/project". I now see that you merged them into one field /dev/sdc1/media/USB_1/project.

    As I said earlier I did not try to see what your rsync command should do (by reading its man page). I simply said to myself that you forgot about the white space. But now I see you are meaning all the time to do something to /dev/sdc1/media/USB_1/project. That can not be true!

    /dev/sdc1 is a device special file and not a directory at all! So this /dev/sdc1/media/USB_1/project can not exist nor being created!

    You are talking about a flash device. Is it possible that this device belongs to the device special file /dev/sdc1 and that it is MOUNTED at /media/USB_1? You can check this with the command
    Code:
    mount
    When this is the case you can create/read/write directories/files on the flash device by using /media/USB_1/ and NOT what you are doing.
    Henk van Velden

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    16,107

    Default Re: Help for a rsync error

    And to add a comment to your
    I do not know if the rw (read|write) permissions are affecting the "rsync" commands.
    Permissions are a property of the file and are used by the kernel to do what has to be done. This has nothing to do with the command that you may happen to use. When a door is closed nobody can get in.
    Henk van Velden

  8. #8

    Default Re: Help for a rsync error

    Quote Originally Posted by hcvv View Post
    You gave a lot of versions. I will stick to the first one:
    Code:
    rsync -P -a -v -H /home/stephen/project/a.file /dev/sdc1/media/USB_1/project
    In your first post there were two fields "/dev/sdc1" and "/media/USB 1/project". I now see that you merged them into one field /dev/sdc1/media/USB_1/project.

    As I said earlier I did not try to see what your rsync command should do (by reading its man page). I simply said to myself that you forgot about the white space. But now I see you are meaning all the time to do something to /dev/sdc1/media/USB_1/project. That can not be true!

    /dev/sdc1 is a device special file and not a directory at all! So this /dev/sdc1/media/USB_1/project can not exist nor being created!

    You are talking about a flash device. Is it possible that this device belongs to the device special file /dev/sdc1 and that it is MOUNTED at /media/USB_1? You can check this with the command
    Code:
    mount
    When this is the case you can create/read/write directories/files on the flash device by using /media/USB_1/ and NOT what you are doing.
    When I wrote the rsync commands I assumed incorrectly that it was necessary to indicate the PATH through the /dev/sdx # fields, and this was causing the error messages posted. All of the storage devices were already mounted: this confusion arose because in the several researches that I made I could not find a proper illustration or example for the general expression here as:

    Code:
    # Local file to Local file
      rsync [options]  Source [Source]  [Destination]
    The several ls -l "/media/device" searches were to indicate that on all of the storage devices there was an existing "/project" directory that I was attempting to write to. After reflecting on your keen insight, for which I am very grateful, I rewrote the shell script in this manner:

    Code:
    #!/bin/sh
    #
    # [the prior comments are omitted for the sake of space]
    #
    rsync -P -a -v -H /home/stephen/project/a.file /media/USB_1/project
    rsync -P -a -v -H /home/stephen/project/a.file /media/USB_2/project
    rsync -P -a -v -H /home/stephen/project/a.file /media/Maxtor_3200/project
    #
    and the desired backup operations are working perfectly well. I dropped the rsync command for the backup to the "/project" directory on the Windows Vista HD since there are blank spaces on a User's name that makes that backup operation to fail entirely.

    Since one can access a NTFS in Linux/Unix I will have to do that backup operation manually by saving the updated a.file to the /media/disk/project directory. In spite of this minor drawback the automated backups performed by the rsync command do help one to save a lot of time! It would be interesting to set up a cron job. Could you refer me a help web page on that matter?

    Thanks once again.

  9. #9
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    16,107

    Default Re: Help for a rsync error

    I am glad I could be of any help to you. May I advise you a few things?

    1) Try to understand what device special files (short: device files) like /dev/sdc1 are. Try to understand what mounting means.

    2) Never write directly to device files. As a normal user you will normaly be blocked from doing so, but as root you will destroy the filesystem on it and loose all data.

    Also do not only read all sorts of howto's or other useful or fatal stories on the web, but at least check them by reading the man pages of the tools involved.

    BTW you not only read man pages by doing in a console/terminal:
    Code:
    man rsync
    but you can also use Konqueror typing man:rsync in the address field.

    And about cron this is the same: first read the man crontab (both sections 1 and 5), then try a few harmless things to get the feeling. When questions stil arise come to the forums here. People on the forum are willing to help you, but not willing to tell you what you can find in the man page

    Basicaly you do
    Code:
    crontab -e
    to edit your crontab (it will probably use vi). Enter a new line by going to the end and typing o (the small letter o). The line will be something as:
    Code:
    10 17 * * *   /the/absolute/path/to/your/script >/tmp/scriptlog 2>&1
    to start the script every day at 10 past 5 in the afternoon. This will also redirect all output to stdout and stderr to the file /tmp/scriptlog (overwriting it every day). Change to your needs. To end the vi-editing, press Esc (to return from input mode to command mode) and type :wq
    Wait until 17:10 and see!
    Henk van Velden

  10. #10

    Default Re: Help for a rsync error

    I edited a crontab for the backup script, and it is indeed amazing to see some of the things that one can do in linux!

    It is also very encouraging to know that the web forums are an invaluable resource not only to find help when needed, but also to understand better the unix man pages that are at times very hard to grasp on a first reading.

    At the same I found an effective way to overcome the Windows drawback due to the blank spaces in the "/media/disk/User/project" field by moving the "/project" directory and placing it in another place --a "/media/disk/Downloads" field that I have on the Windows Vista NTFS install.

    Code:
    rsync -P -a -v -H /home/stephen/project/a.file /media/disk/Downloads/project
    I trust that this feedback may be useful to help other persons that might face a similar situation as mine.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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