Show system backup toggle on edit remote too
The sysbackup toggle is now available for both add and edit flows, so users can trigger a system backup against any existing remote. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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{</div>\n</div>\n};
|
||||
|
||||
# Initial System Backup toggle (add mode only)
|
||||
unless ($is_edit) {
|
||||
# System Backup toggle
|
||||
my $sysbackup_checked = $form->{'sysbackup_toggle'} ? ' checked' : '';
|
||||
print qq{<div class="card bg-white shadow-sm border border-base-300 mb-6">\n<div class="card-body">\n};
|
||||
print qq{<h2 class="card-title text-sm">Initial Backup</h2>\n};
|
||||
print qq{<h2 class="card-title text-sm">System Backup</h2>\n};
|
||||
print qq{<div class="flex items-center gap-3 mb-2.5">\n};
|
||||
print qq{ <label class="w-44 font-medium text-sm" for="sysbackup_toggle">Run system backup</label>\n};
|
||||
print qq{ <input type="checkbox" class="toggle toggle-sm toggle-success" id="sysbackup_toggle" name="sysbackup_toggle" value="1"$sysbackup_checked>\n};
|
||||
print qq{</div>\n};
|
||||
print qq{<p class="text-xs text-base-content/60 mt-2">Backs up WHM/cPanel config, installed packages, and cron jobs to the new remote immediately after creation. Runs in the background.</p>\n};
|
||||
print qq{<p class="text-xs text-base-content/60 mt-2">Backs up WHM/cPanel config, installed packages, and cron jobs to this remote. Runs in the background.</p>\n};
|
||||
print qq{</div>\n</div>\n};
|
||||
}
|
||||
|
||||
# Submit
|
||||
print qq{<div class="flex gap-2 mt-4">\n};
|
||||
|
||||
Reference in New Issue
Block a user