rsync option --log-file seems is not working

04
2013-09
  • Questioner

    I am using the --log-file option in rsync to see the logs. But when I tried to run, it says:

     --log-file unrecognized option
    

    Here is my command:

    #/usr/bin/rsync -av -u --log-file="/sreeni/log.txt" --rsync-path=/usr/local/bin/rsync /sreeni nnmhpt20.ind.hp.com:/sreeni
    

    could some one help me with the right syntax ?

    I tried these options also.

    #/usr/bin/rsync -av -u --log-file /sreeni/log.txt --rsync-path=/usr/local/bin/rsync /sreeni nnmhpt20.ind.hp.com:/sreeni
    

    and

    #/usr/bin/rsync -av -u --log-file="/sreeni/log.txt" --rsync-path=/usr/local/bin/rsync /sreeni nnmhpt20.ind.hp.com:/sreeni
    
  • Answers
  • Joao Figueiredo

    Which is your distro? For an agnostic distro aproach you can use simple output redirection.

    rsync your_chosen_options >> chosen_logfile 2>&1

    which turns into,

    /usr/bin/rsync -av -u /sreeni nnmhpt20.ind.hp.com:/sreeni >> /sreeni/log.txt 2>&1
    

    Anyways for Debian based boxes, this seems to work,

    rsync -av -u --log-file=/var/log/atest.log SRC DEST 2>&1 1>/dev/null
    

    whereas for RHEL I needed,

    rsync -av -u SRC DEST 1>>/var/log/atest.log 2>/dev/null
    
  • moltisanti

    this expression works for me (ubuntu 12.10):

    sudo rsync -axzuvh --force --delete --no-whole-file --log-file=/var/log/atest.log SRC DEST
    

    remember using sudo.


  • Related Question

    rsync delete options
  • Skilldrick

    I see on the rsync man page that there are a number of delete options. I don't really understand the differences and implications of each of these - could someone fill me in please?

     --del                   an alias for --delete-during
     --delete                delete extraneous files from dest dirs
     --delete-before         receiver deletes before transfer (default)
     --delete-during         receiver deletes during xfer, not before
     --delete-delay          find deletions during, delete after
     --delete-after          receiver deletes after transfer, not before
     --delete-excluded       also delete excluded files from dest dirs
    

  • Related Answers
  • lesmana
    • --del/--delete_during: Deletes files from the destination dir as they are copied (saves memory compared to --delete-before: --delete-before makes a separate scan to look for deleteables)

    • --delete: Deletes files in the destination directory if they don't exist in the source directory.

    • --delete-before: Delete files in the destination directory before coping file-with-same-name from source directory

    • --delete-during: Delete files in the destination directory WHILE copying file-with-same-name from source directory

    • --delete-delay: Mark deletes during transfer, but wait until transfer is complete

    • --delete-after: Receiver deletes after transfer, not before...If some other part of the rsync moved extra files elsewhere, you'd want this instead of --delete-delay, because --delete-delay decides what its going to delete in the middle of transfer, whereas --delete-after checks the directory for files that should be deleted AFTER everything is finished.

    • --delete-excluded: Deletes files from the destination directory that are explicitly excluded from transferring from the source directory.

    The point of rsync is not copying, it is archiving. This is an important distinction. Processing deleted/changed files is critical, and in many cases nuanced.

    The --delete flag in particular is one I've seen screwed up many times. Lot of people use rsync to move files to low priority storage, so you want the files you're moving to still EXIST in the destination directory. That's not what delete does: --delete makes sure that, when you delete a file from the source directory, it is ALSO deleted from your destination directory, so your destination doesn't get full of junk...Once saw a guy wipe out his backup by putting in a new drive, and not turning off his nightly rsync script. Script saw that the source dir was now empty, and it deleted every file in the destination dir, so they'd match.

    Most of the other options are space or performance related. When you delete the files is important if you want to make sure the transfer is successful before you do anything, but if your device is too small to handle 2 copies of all the information, you need to delete as you go, etc. It's a little wacky because of it's long history across multiple platforms: some options have been added so that people who were used to certain behaviour wouldn't be confused.

  • Michael Pryor

    There are two things going on:

    1. Who does the deleting
    2. When it happens

    Either the sender or the receiver can be instructed to do the deleting (I'm not sure why this matters). So when rsync from one computer connects to the rsync server on the other side, this determines who is effectively issuing the delete command.

    When it happens is pretty easy... before means all the files are deleted, and THEN rsync copies over the files. during means as it goes through the list of files, it deletes them when it comes to them, and after means it waits until all the files are transferred over and then deletes the remote side. This matters only when the transfer gets interrupted.

  • Walt Stoneburner

    One other point worth mentioning is that if your source directory ends with /*, then rsync will only consider those files and not the directory itself (and thus the absence of files that you want deleted on the destination).

    If you're specifying a delete option above, but rsync looks like it isn't deleting, then check to make sure you're not accidentally globing and providing a list of files when you mean the directory itself.