Provide Remote Shutdown Option in Replication Task Configuration

willcycle

Dabbler
Joined
Sep 22, 2018
Messages
24
I use a TrueNAS server to backup my main server. Since this server is only used for backups there is no need to keep it running 24/7. To create backups now, I configured a cron job to 'wake on lan' my backup server, automatically have a snapshot taken and perform a replication on my main server 15 minuets later, and after four hours I have a cron job on my back server shut it down. Having an option on my main server to automatically shut down the remote backup server after replication completes would be very useful. This way I don't have to guess how long to keep the backup active for the replication to finish.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,681
IMO, that's super-unlikely to happen, because the target market for TrueNAS doesn't shut down servers ever, and this creates a case where someone who inadvertently ticks a checkbox could cause a lot of mayhem to another filer that might not be just a replication target, but, y'know, actually doing real work too.

Since you've already created a cronjob that does the snap and replication, why don't you just add

ssh <backupserver> shutdown -p now

to the end of your script?
 

willcycle

Dabbler
Joined
Sep 22, 2018
Messages
24
I use the shutdown command on the backup server in a cron job which is not activated for a few hours to make sure the replication job is complete first.
To prevent what you are saying, as part of the activation you would have to put in the target MAC address and you can require the root password as well.
 

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,828
IIRC, if you append the shutdown command to the backup command in the cron job using a "&&", then the shutdown command only gets executed if the backup completed successfully first. Waking up the remote server consistently and reliably on time may require a think or two as well.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,681
I use the shutdown command on the backup server in a cron job which is not activated for a few hours to make sure the replication job is complete first.
To prevent what you are saying, as part of the activation you would have to put in the target MAC address and you can require the root password as well.

I'm not sure what you're saying.

You say you already have a script that does your WOL and snapshot.

I'm saying that if your script is

#! /bin/sh -

wake em0 <lladdr>
zfs snapshot <somefoo>
zfs send <somefoo> | ssh <remotehost>

Then what you want is to add

ssh <backupserver> shutdown -p now

to the end of this.
 
Top