diff --git a/whm/gniza-whm/remotes.cgi b/whm/gniza-whm/remotes.cgi index 4d65341..0ecbba0 100644 --- a/whm/gniza-whm/remotes.cgi +++ b/whm/gniza-whm/remotes.cgi @@ -430,7 +430,25 @@ sub handle_edit { if (!@errors) { my ($ok, $err) = GnizaWHM::Config::write($conf_path, \%data, \@GnizaWHM::Config::REMOTE_KEYS); if ($ok) { - GnizaWHM::UI::set_flash('success', "Remote '$name' updated successfully."); + # Fork sysbackup if toggle is on + my $sysbackup_msg = ''; + if ($form->{'sysbackup_toggle'}) { + my $log_file = "/var/log/gniza/sysbackup-$name.log"; + my $pid = fork(); + if (defined $pid && $pid == 0) { + close STDIN; + close STDOUT; + close STDERR; + open STDIN, '<', '/dev/null'; + open STDOUT, '>', $log_file; + open STDERR, '>&', \*STDOUT; + exec '/usr/local/bin/gniza', 'sysbackup', "--remote=$name"; + exit 1; + } + $sysbackup_msg = ' System backup started in background.' if defined $pid; + } + + GnizaWHM::UI::set_flash('success', "Remote '$name' updated successfully." . $sysbackup_msg); print "Status: 302 Found\r\n"; print "Location: remotes.cgi\r\n\r\n"; exit; @@ -651,18 +669,16 @@ sub render_remote_form { _field($conf, 'RETENTION_COUNT', 'Snapshots to Keep', 'Default: 30'); print qq{\n\n}; - # Initial System Backup toggle (add mode only) - unless ($is_edit) { - my $sysbackup_checked = $form->{'sysbackup_toggle'} ? ' checked' : ''; - print qq{
Backs up WHM/cPanel config, installed packages, and cron jobs to the new remote immediately after creation. Runs in the background.
\n}; - print qq{Backs up WHM/cPanel config, installed packages, and cron jobs to this remote. Runs in the background.
\n}; + print qq{