Help with output redirect please.

  • I have loaded my Rock64 with LibreElec, and I am also using it as my Samba server.

    I want to run a sync between the two USB hard drives I have attached to maintain a backup of my media.

    I can't seem to get the command quite right. I want to copy the data, and redirect the output to a text file so I can see what it is doing later on.

    I do want it to overwrite the old log file.

    This is the command I am trying to use:

    Code
    rsync -rav --modify-window=300 --homan-readable --progress  --stats --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/ |& tee /var/media/8TB_WD2/synclog.txt 
    
    -sh: syntax error: unexpected "&"

    I have also tried > but I get no log file output at all.

    Code
    rsync -rav --modify-window=300 --homan-readable --progress  --stats --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/ > /var/media/8TB_WD2/synclog.txt 

    If I cut off the redirect, it outputs to bash exactly what I would expect, but I can't get it to output to a log file.

    Works with output to bash ->

    Code
    rsync -rav --modify-window=300 --homan-readable --progress  --stats --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/

    Can someone make a suggestion. I am probably missing something crazy simple, but just can't see it.

    PS for some reason the word hu.man is censored here. Please replace the homan with hu.man when reading my code above.

  • Maybe try

    rsync -rav --modify-window=300 --homan-readable --progress --log-file=var/media/8TB_WD2/synclog.txt --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/ &>/dev/null

  • It would be nice to get the output in the terminal and the log file, but I can live with not having it in the terminal.

    Thanks for the suggestion, but no luck. The rsync starts, but there is no log file.


    I am using almost identical code on my dd-wrt router, and it works there as expected.

    Code
    DD-WRT:
    rsync -rav --modify-window=300 --hu.man-readable --progress  --stats --force --delete /tmp/mnt/8TB_USB/ /tmp/mnt/5TB_Seagate_USB/ > /tmp/mnt/8TB_USB/rsync_Status.txt

    Edited once, last by wizardknight (December 22, 2017 at 12:56 AM).

  • from the man page

    Code
    --log-file=FILE
    This option causes rsync to log what it is doing to a file.  This is similar to the logging that  a  daemon  does,  but  can  be
    requested  for  the client side and/or the server side of a non-daemon transfer.  If specified as a client option, transfer log‐
    ging will be enabled with a default format of "%i %n%L".  See the --log-file-format option if you wish to override this..
  • Just tried both suggestions, and there was no log file created.

    Suggestion #1

    Code
    rsync -rav --modify-window=300 --hu.man-readable --progress --log-file=/var/media/8TB_WD2/synclog.txt --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/ &>/dev/null


    Suggestion #2

    Code
    rsync -rav --modify-window=300 --hu.man-readable --progress --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/ 2>&1 | tee /var/media/8TB_WD2/synclog.txt


    Terminal output:

    Code
    ^CLibreELEC:/var/media/8TB_WD2/Media/Movies # rsync -rav --modify-window=300 --hu.man-readable --progress --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/ 2>&1 | tee /var/media/8TB_WD2/synclog.txt
    
    sending incremental file list
    deleting synclog.txt
    ./
    Media/Epsoides/Hogans Heroes/Hogans.Heroes.S1.DVDRip/
    Media/Epsoides/Hogans Heroes/Hogans.Heroes.S1.DVDRip/Hogans.Heroes.1x32.dvdrip.xvid-BBBear_TMindTV.avi
            314.32M 100%   50.49MB/s    0:00:05 (xfr#1, ir-chk=1013/63529)

    Second SSH to check for log file:

    Am I missing something, or is the system not working right?

    I feel like an idiot. I can't see any reason why all of these would fail to generate some kind of output file.

    I did just notice a .fuse_hidden0000f49000000005 file being created when I kick off these commands.

    I am assuming that is a temp file for rsync, but it is the only thing at the root of that drive which is new.

    It also vanishes when I kill the rsync command.


    Thanks for the suggestions. :)

    Maybe I need to get out my voodoo chicken bones and grass skirt...

    Could be running low on magic smoke.

    Edited 2 times, last by wizardknight (December 22, 2017 at 9:45 PM).

  • I didn’t test to output the log to the destination disk maybe is getting deleted at the end. Try another location maybe /storage for the log file

    I redirected the log to storage, and it worked. A gold star to you.

    Code
    rsync -rav --modify-window=300 --hu.man-readable --progress --log-file=/storage/backup/synclog.txt --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/ &>/dev/null
    Code
    LibreELEC:~/backup # ls
    synclog.txt

    Now the question is why can't I write to my external HD as root? That is just all kinds of special.


    nickr

    Can you tell me why hum.an is a censored word? I have to admit I am curious.

    Is this place ran by aliens, or powered by the screams of children? That would make sense.

  • No I don't know, I was going to correct you on your options, but it wouldn't let me, and I realised that your post was deliberately misspelled.

    I'll see if someone higher up the foad chain can help with that.

    PS apparently f o o d is banned too.

  • No I don't know, I was going to correct you on your options, but it wouldn't let me, and I realised that your post was deliberately misspelled.

    I'll see if someone higher up the foad chain can help with that.

    PS apparently f o o d is banned too.

    It must be aliens. They don't want the secret getting out. Homans are f00d!

    hqdefault.jpg

  • Resolved.

    I am not sure how, but I can redirect to my external hd now.

    The command is the same as the one I first tried.

    Code
    rsync -rav --modify-window=300 --homan-readable --progress  --stats --force --delete /var/media/8TB_WD/ /var/media/8TB_WD2/ > /var/media/8TB_WD2/synclog.txt

    I guess I was not biting my tongue just right.

    Now to stick it in cron and see if it plays nice there...