WakeOnLan the Backup-PC, then replicate, then shutdown

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

algato

New Member
Sep 18, 2013
13
0
1
Hello,

I just have built my first backup system using napp-it's replication module.

server -> omnios + napp-it
backup -> omnios + napp-it

The backup consists of four single replication jobs of single zfs filesystems. These are only few data and the replications last for only few minutes.

It would suffice completely if the server could send a WakeOnLan command to the backup-PC, for example 5 minutes before the replication starts and then the Backup-PC would turn himself off after the replications are done.

Has anyone of you already realized something like that?

Gea, is there the possibility of integrating these functions in the napp-it gui?


Additional question: is it unimportant if the four replication jobs start at the same time? or is it better for the performance if they were worked off after each other?

Kind regards and thank you in advance for your response
Alex
 

gea

Well-Known Member
Dec 31, 2010
3,163
1,195
113
DE
Sun and then Oracle had never included WoL into Solaris as an enterprise OS does simply never need.
Now when we have Solaris at home mainly with the OpenSource forks, this may be different but
up to now it was not included propably because the main companies behind like Delphix, OmniTi, Joyent
or Nexenta do not need as well.

I would simply power on when needed and shutdown via job afterwards.
As a simple tech you can use a timer based power switch
 

algato

New Member
Sep 18, 2013
13
0
1
The backup-Pc is a pretty HP Microserver N54L gen 8 cube. The microserver reacts to a WOL command, this can be turned on in the bios.
The WOL I can realise with a windows tool, it works.
How can I do the turn off part of the task ? How can I build a script, which checks if a replication job is still running and if no , then turns the backup-pc off ?
 
Last edited:

xnoodle

Active Member
Jan 4, 2011
258
48
28
You could stick all 4 jobs in a shell script, add a shutdown at the end and set it to run on start up.

Sent from my HTC One using Tapatalk
 

EffrafaxOfWug

Radioactive Member
Feb 12, 2015
1,394
511
113
I do a similar thing with my backup server, namely powering it up with wakeonlan from the main server, running the backup sync jobs from anacron.

I decided not to opt for the shutdown-at-the-end option because frequently the system would be doing something else, so I set up a separate script that runs every half hour to handle the shutdown which checks for the following via a series of if/foreach loops:
If any rsync processes are running
Code:
ps -aux|grep rsync|grep -v grep|grep -v daemon|wc -l
If any users are logged in
Code:
users|wc -w
If any SMART self-tests are running across any of the drives in /dev/sdX
Code:
smartctl --log=selftest /dev/sda|grep offline|grep -v error|wc -l
If any mdadm jobs/resyncs are running or if any RAID arrays have failed
Code:
grep -v idle /sys/class/block/mdX/md/sync_action|wc -l
cat /sys/class/block/mdX/md/degraded
If all those return zero, server shuts down. Inelegant I'm sure but works reliably and I'm sure someone else can chip in with the solaris equivalents for checking ZFS status, etc. You could also just configure create a temp/PID flag file in /tmp or /var/run or similar and have your backup scripts clean that up when they're done but as mentioned this wouldn't stop the scenario where you might not want the server to shut down.
 

gea

Well-Known Member
Dec 31, 2010
3,163
1,195
113
DE
The backup-Pc is a pretty HP Microserver N54L gen 8 cube. The microserver reacts to a WOL command, this can be turned on in the bios.
The WOL I can realise with a windows tool, it works.
How can I do the turn off part of the task ? How can I build a script, which checks if a replication job is still running and if no , then turns the backup-pc off ?
# a simple Perl scipt may be something like
Code:
$r=`ps axw | grep 'zfs receive' | grep -v grep`;
if  ($r eq "") {
    `sudo init 5`;
}
If you run it every 30 minutes it will shutdown without a running zfs receive