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

Thread: rsync: trouble with syntax

  1. #1
    Join Date
    Oct 2009
    Location
    frisco-->native
    Beans
    324
    Distro
    Ubuntu

    rsync: trouble with syntax

    hi all,

    I have decided to learn how to back up more efficiently and stumbled upon
    rsync.

    I want to backup my music directory, which consists of mostly single files and some directories that contain albums.

    I thought it was pretty easy but it seems I'm doing something wrong.Here's what I tried:
    Code:
    sudo rsync -r ~/Music/*.*  /media/LinuxBU/MusicBU
    where LinuxBU/MusicBU is my music mack up directory on an external USB drive.
    It did copy the files, but not the directories, and when I tried again, it didn't seem to skip
    what was already there, and my machine froze up for the first time since installing Ubuntu...

    thanks for your help,
    wbg
    Lenovo ThinkPad T400 Core 2 Duo 4GB Ram Mint 13 XFCE
    500 GB spinning iron and 64 GB Crucial SSD in DVD bay.

  2. #2
    Join Date
    Jun 2009
    Location
    0000:0400
    Beans
    Hidden!

    Re: rsync: trouble with syntax

    *.* is a DOS'ism. Specifying the folder alone is enough. I'd also recommend not doing this as root. If you're unable to write to your external drive any other way, you need to solve that problem first.

  3. #3
    Join Date
    Aug 2008
    Beans
    Hidden!

    Re: rsync: trouble with syntax

    It's good to add the -v parameter so it reports more of what's going on.

    Also I think your first syntax will not preserve attributes and timestamps, so on the second run, files don't match and have to be copied again. The -a parameter sorts this out.

    Code:
    rsync -rva ~/Music/* /media/LinuxBU/MusicBU

  4. #4
    Join Date
    Oct 2009
    Location
    frisco-->native
    Beans
    324
    Distro
    Ubuntu

    Re: rsync: trouble with syntax

    hey, thanks folks...

    I saw the preserve time stamp option in the man but thought it was supposed to be default.

    I tried the above code and go an error:
    rsync: failed to set times on "/home/daniel/LinuxBU/.": Operation not permitted


    also, I mount the USB drive on my home directory to avoid sudo...
    any ideas? I

    wbg
    Last edited by wannabegeek; February 19th, 2010 at 07:38 AM.
    Lenovo ThinkPad T400 Core 2 Duo 4GB Ram Mint 13 XFCE
    500 GB spinning iron and 64 GB Crucial SSD in DVD bay.

  5. #5
    Join Date
    Oct 2009
    Location
    frisco-->native
    Beans
    324
    Distro
    Ubuntu

    Re: rsync: trouble with syntax

    hi again,
    from home dir I tried:
    Code:
    sudo rsync -rsv Music/Mozart LinuxBU
    and it seems to have to copied the files with time stamps...
    gonna try the whole thing again and see if the directories get in there.

    wbg
    Last edited by wannabegeek; February 19th, 2010 at 07:51 AM.
    Lenovo ThinkPad T400 Core 2 Duo 4GB Ram Mint 13 XFCE
    500 GB spinning iron and 64 GB Crucial SSD in DVD bay.

  6. #6
    Join Date
    Aug 2008
    Beans
    1,835
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: rsync: trouble with syntax

    If you are more comfortable with GUI apps, there is a graphical front end available to rsync in the repositories called grsync. It doesn't provide all the available rsync features but may do what you want. An advantage of it is that it allows to create "sessions" which you can use again and again to perform the same backup task. The project seems to be in active development with two releases having come out since the version in the karmic repos.

  7. #7
    Join Date
    Aug 2009
    Location
    Australia
    Beans
    42
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: rsync: trouble with syntax

    I use rsync to sync all media between two media centres.

    Code:
    rsync -au --compress --stats --human-readable --exclude=.Trash-1000 /source /destination

    -a, --archive
    This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve everything.

    -u, --update This forces rsync to skip any files for which the destination file already exists and has a date later than the source file.

    -z, --compress
    With this option, rsync compresses any data from the source file(s) which it sends to the destination machine. This option is useful on slow links. The compression method used is the same method that gzip uses.

    --stats
    This tells rsync to print a verbose set of statistics on the file transfer, allowing you to tell how effective the rsync algorithm is for your data.

    -h, --human-readable
    Print sizes in human readable format (e.g., 1K 234M 2G)


    If you what to automated it with crontab so to make sure that rsync does not run if your hard drive is not plugged create a blank file in the root of your destination and add before your rsync statement.

    Code:
    if [ -f /destination/control.file ]
        then echo "Hard Drive connected"
        else echo "Hard Drive not connected" && exit
        fi
    What this does is make sure the file "control.file" exists. If it doesn't the script will quit before running rsync.
    Last edited by lijcam; February 19th, 2010 at 10:53 AM. Reason: Corrected Syntax

  8. #8
    Join Date
    Dec 2009
    Location
    germany
    Beans
    1,020
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: rsync: trouble with syntax

    hi lijcam
    this is a good explanaition how to do it.
    but "fi" not done
    ciao
    "What is the robbing of a bank compared to the FOUNDING of a bank?" Berthold Brecht

  9. #9
    Join Date
    Aug 2009
    Location
    Australia
    Beans
    42
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: rsync: trouble with syntax

    Hey thanks for that rnerwein have made the correction.

    Also for got to add while you are playing with rsync make sure you add the dry run switch.

    -n, --dry-run show what would have been transferred.

  10. #10
    Join Date
    Oct 2009
    Location
    frisco-->native
    Beans
    324
    Distro
    Ubuntu

    Re: rsync: trouble with syntax

    wow,THANKS lijcam

    kick *** reply...

    There iseems to be a sublte difference between the two codes below:
    Code:
    $rsync -au ../source/  target 
     $rsync -au ../source /target
    the second command creates a new directory in the target location, while the first
    copies into the target like I would have expected.

    Am I wrong ?

    thanks again,
    wbg
    Last edited by wannabegeek; February 20th, 2010 at 10:01 PM.
    Lenovo ThinkPad T400 Core 2 Duo 4GB Ram Mint 13 XFCE
    500 GB spinning iron and 64 GB Crucial SSD in DVD bay.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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