Auto Sleep / Shutdown After Rsync is completed

  • Hi All,

    Hoping you can help. I have two OMV servers at home, a main and a second that backs up everything from the first once a month. I want to avoid having the second on all the time and using power, spinning disks for no reason.


    I thought that the best way to do this might be to have the backup server "sleep" after the Rsync job is completed. Then, in a month's time, Main server wakes the backup server in preparation for the next sync.


    So my question is, what is the easiest (software) solution I might use? The only thing I can find so far is using the autoshutdown plugin on the backup server + WOL from main. My questions are;

    1) Is this the simplest solution?

    2) Does WOL only wake a server from Sleep, or also from being shutdown? I am not sure if the proposed combo would even work
    3) If the above is all good - What autoshutdown argument is best to identify if rsync is running / done? Is there some flag I can use, or do I need to look at Hdd activity somehow?

    • Offizieller Beitrag

    1) Is this the simplest solution?

    2) Does WOL only wake a server from Sleep, or also from being shutdown? I am not sure if the proposed combo would even work
    3) If the above is all good - What autoshutdown argument is best to identify if rsync is running / done? Is there some flag I can use, or do I need to look at Hdd activity somehow?

    1) Since the copies are executed once a month, the simplest thing is to turn it on manually (it's what I do). Why have a server on standby for a month? The safest server is the one that is turned off. ;)


    2) WOL activates a server from the BIOS. If it's just suspended it should respond without WOL. Maybe I'm wrong about this. I have never put a server to sleep.


    3) That is a good question. I would also like to know the answer. Maybe a script could do the rsync job and then shut down the server.

    A checkbox in the OMV rsync task to shut down the server on completion could be a nice feature for many.

  • Hi Chente, thanks for your time

    My concerns with manual are mainly that I am forgetful, but also that my files are large and change often - and as Rsync doesn't show progress, I won't even know when the job is done. I get slow speeds for backup so could be days.

    Also, my plan is to hide this server away in the attic, and I'm too plain lazy to go up there every month XD

    • Offizieller Beitrag

    This situation has been raised several times in the forum. I don't remember the exact answers. If you do a search (better use google) you should get answers to this.

    I still think that checkbox in the rsync tasks to shut down the server when the job is done would be useful. Maybe votdev consider it?

  • I did do a bit of google reading for solutions but sadly couldn't find something just like my situation.


    macom many thanks for the tip - do you have an idea of what command I would send in Rsnapshot to send the server to sleep?

    I'm guessing that WOL doesn't work if the server is fully shutdown?

    Also - I might be wrong, but Rsnapshot doesn't support remote servers? Isn't it just for locally mounted files?

    • Offizieller Beitrag

    do you have an idea of what command I would send in Rsnapshot to send the server to sleep?

    shutdown should work


    If you want that the server wakes up itself (without WOL) you can run something like

    rtcwake -m off -t $(date -d "next sat 7:00" +%s)


    Which will wake it up on next Saturday at 7:00 AM.

    Also - I might be wrong, but Rsnapshot doesn't support remote servers? Isn't it just for locally mounted files?

    Right. You would have to use the remotemount plugin to create a share that is locally accessible.

  • Evening! So, I added remotemount plugin, mapped the main server. Also Tested WOL, works great waking up the backup.

    Now my task is to setup the rsync/rsnapshot followed by a shutdown command.

    I had a good play with Rsnapshot, but for some reason it finishes extremely fast, and the backup directory appears empty.

    Does Rsnapshot copy all files from Source A to Destination B like Rsync does? Or does this hardlinking thing work differently?

    My hope and aim is to have a like-for-like copy of my original data, on the second server - as another SMB share

    • Offizieller Beitrag

    Does Rsnapshot copy all files from Source A to Destination B like Rsync does?

    Nope. Rsnapshot is creating snapshots of the files. If a file is not changed from one snapshot to the next, it will be hardlinked. If the file changed it will be the file itself.

    The idea of rsnapshot is to have a versioned backup that is using little extra space on the filesystem.


    So you end up with folders like

    daily.0

    daily.1

    daily.2

    weekly.0

    weekly.1

    weekly.2


    and each of the folders is containing a complete set of you files (mostly hardlinked).


    I had a good play with Rsnapshot, but for some reason it finishes extremely fast, and the backup directory appears empty.

    Check the logs , if there is an error message.

    I hope there is no limitation of using rsnapshot in combination with a remote mount.

  • Hi Guys - so, Rsnapshot in the logs says completed successfully, but folders are empty. In any case, I don't think I want this result - I'm leaning towards Rsync as this gives me the "clone" of my data I want

    I found some mentions here in the forum that I can simply have OMV run a script as a scheduled job, one of these solutions;

    Trouble is I have no idea how to write, make or schedule this script! Could you point me in the right direction?


    #!/bin/bash

    while ! pgrep -x rsync; do

    sleep 2

    done

    shutdown -h now



    Or


    #!/bin/bash

    rsync #1 &&

    rsync #2 &&

    rsync #3 &&

    rsync #4

    shutdown now

  • So, I think I have two solutions, although struggling to get them to work.


    Option 1 - Preferred - Use the "Autoshutdown Plugin" to shutdown when Rsync is done. Not sure how to find what Rsync process is called to add it to the checks plugin has. Then figure out how to send a WOL via scheduled task from main server. Again, not sure what this command looks like - I have the "WOL plugin" and that works fine.


    Option 2 - Backup plan - Use scheduled tasks to simply force shutdown every morning. Rsync set to always startup, and set to "resume" where it left off. Bit crude and probably not good for my hardware!

    I'd love to get option 1 going. Any thoughts on

    1) What process Rsync is referred to, so I can tag it in autoshutdown plugin

    2) in task scheduler - what command would I send to WOL the other server?

    I have been googling but not sure what im doing wrong, can't find the answer! Forgive me, im more of a hardware than software guy

    • Offizieller Beitrag

    Maybe you could do the following:

    • Schedule an automatic server startup at time X.
    • Set up a scheduled task in the GUI, at X hours plus 5 minutes, similar to this:
      • [rsync task command] && shutdown

    I've never tried anything like this, but I don't see why it wouldn't work. Check the concatenator &&, maybe it is not the right one.

  • Maybe you could do the following:

    • Schedule an automatic server startup at time X.
    • Set up a scheduled task in the GUI, at X hours plus 5 minutes, similar to this:
      • [rsync task command] && shutdown

    I've never tried anything like this, but I don't see why it wouldn't work. Check the concatenator &&, maybe it is not the right one.

    Automatic Startup - how do arrange that, is that from RTC wake??

    The Rsync command + Shutdown, I am not sure how to do this from CLI - do you have any examples I can look at?

  • So, I think I managed to get it working just how I wanted it. I'll summarise below for any other newbies like me who are struggling;

    Main Server - Send WOL command to backup server - "scheduled task" - wakeonlan XX:XX:XX:XX:XX (enter mac address here)
    Main Server - few minutes later, start RSYNC as per GUI settings

    Backup Server - enable Auto Shutdown plugin. I used HDD activity to poll if the backup server is active or not. would much prefer to use RSYNC PROCESS ID/NAME but can't find out what this is.

    So, when RSYNC is done, and backup server is idle, the countdown to auto-shutdown begins! I'm doing my sync in the middle of the night once a week to be cheap.

    If anyone knows what the process name for RSYNC is to use in autoshutdown, would be fantastic - I read it could be "in.tftpd" ??

    • Offizieller Beitrag

    Automatic Startup - how do arrange that, is that from RTC wake??

    Your BIOS may allow it.

  • this is now working for me, last night it woke the backup server, did the rsync and then went back to sleep.

    As chente says, I think that having a checkbox in rsync to shutdown on completion - (or CLI to run before + after sync) might be a welcome addition to many!

    I think you can close this thread now - thanks all for your time :)

  • macom

    Hat das Label gelöst hinzugefügt.
  • Don't suppose either of you could share screenshots of your config for this please?

    Looking into something similar as an offsite backup solution, and have been considering a similar approach, just want to make sure it is relatively easy to setup.

    thanks!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!