Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Replicate on startup and shutdown after replication

ali_v001

Member
Joined
Aug 10, 2020
Messages
28
Hey guys. I have set up a replication server... all is running well..

Are there any simple scripts / cron jobs that could help me to, start a replication task as soon as the server is booted up and then shutdown the server once the replication task has finished? I'd prefer the shutdown task to not be time-based but rather when the actual replication task completes. Although if time-based is much easier then It could suffise.

The replication server is set to PULL data from the main appliance as I thought this would simplify the automation of starting the job shutting down the machine

I am trying to save energy and only have my main FreeNAS server running 24/7
Atm, my replication server is just built from spares I had lying around... no ipmi etc.

So atm I plan on just manually switching this server every day or two. ideally, I would be able to autostart it at specific times. But this should do for now.

Thanks
 

Number1Onion

Neophyte
Joined
Mar 8, 2017
Messages
9
Hey guys. I have set up a replication server... all is running well..

Are there any simple scripts / cron jobs that could help me to, start a replication task as soon as the server is booted up and then shutdown the server once the replication task has finished? I'd prefer the shutdown task to not be time-based but rather when the actual replication task completes. Although if time-based is much easier then It could suffise.

The replication server is set to PULL data from the main appliance as I thought this would simplify the automation of starting the job shutting down the machine

I am trying to save energy and only have my main FreeNAS server running 24/7
Atm, my replication server is just built from spares I had lying around... no ipmi etc.

So atm I plan on just manually switching this server every day or two. ideally, I would be able to autostart it at specific times. But this should do for now.

Thanks
I'm looking to solve this same issue. Have you found a solution?
 

ali_v001

Member
Joined
Aug 10, 2020
Messages
28
Unfortunately not, I've kind of given up on replication for the time being, would love to get it working at some point!
I find my replication works for a while then if I shut down the machine and start it up a week or two later the replication task fails. Yet to dig any deeper, as for automated on and off I haven't had any replies!
So yeah please guys any advise would be great!
 

no_connection

Senior Member
Joined
Dec 15, 2013
Messages
448
For starting there is usually some sort of schedule in BIOS to turn on. Or wake on lan from a router or similar.

For turn off maybe a script that runs every 10min and check for a finished status? Maybe with some sanity checks baked in.
 

ali_v001

Member
Joined
Aug 10, 2020
Messages
28
Hey, I think the automation question to start up, replicate, then shutdown is more a question of the actual scripts. Rather than the theory of how it works.
Im very familiar with wake on lan and how scripts work but for this particular question it was more of a "what are the scripts / commands to execute. How would it be best written and executed.
So I think there are 3 parts to this task.

Start system - Wol, scripted from another box or ipmi?
Start Replication once the server is up and running - Cron job or startup job? To start the replication task once the server has booted.
Shutdown system - Another Cron job? Or job dependent on the above job? to then send a shutdown command.

So I'll ask the forums again, does anybody know what these scripts would look like? I imagine one simple .sh script could suffice?
I'm assuming time based execution would not be great here apart from the initial boot machine job, but the replicate and shutdown would be respectively dependent on the machine startup job.

Any advice as to why or why this would not work? Working examples of scripts would be ideal.

I think this would be very helpful for both home users and business users that are conscious of energy use and the environment.

Thanks
 

neb50

Member
Joined
Aug 15, 2017
Messages
28
I used to do this a couple years ago.

cron job on main server that would start backup server using IPMI
cron job to enable periodic replication tasks on main server
periodic replication tasks set to run on main server while backup server was running (15 minutes after boot)
smart tests and scrubs set to run after replication finished
cron job to disable periodic replication tasks on main server
cron job to initiate shutdown on backup server

The backup server was started at 1am Saturday morning and then the replication task would start at 1:15 and run through ~10am Saturday morning. Smart tests and scrubs were set to run on alternating weekends (short, scrub, short, long). I would let it run through Sunday morning to complete a second replication and then shutdown at 10am.

The cron job to enable and disable replication just copied a modified version of the replication task (autosnap.py) and overwrote the one in the system folder that would cause periodic replications to be enabled or disabled since I wasn't able to find an easy way to disable them based on days and it worked. A day of the week periodic replication task has been suggested many times, but the dev's don't want to add it as an option.
 
Top