HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/share/webmin/virtual-server/delete-scheduled-backup.pl
#!/usr/bin/perl

=head1 delete-scheduled-backup.pl

Delete a scheduled backup for one or more virtual servers

This command removes the scheduled backup identified with the C<--id> flag,
which must be followed by the backup's unique numeric ID. Or you can select
a backup with C<--dest> followed by a backup destination path.

This only prevents future backups from happening on schedule, and it does not
remove any existing backup files.

=cut

package virtual_server;
if (!$module_name) {
	$main::no_acl_check++;
	$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
	$ENV{'WEBMIN_VAR'} ||= "/var/webmin";
	if ($0 =~ /^(.*)\/[^\/]+$/) {
		chdir($pwd = $1);
		}
	else {
		chop($pwd = `pwd`);
		}
	$0 = "$pwd/delete-scheduled-backup.pl";
	require './virtual-server-lib.pl';
	$< == 0 || die "delete-scheduled-backup.pl must be run as root";
	}
&licence_status();

# Parse command-line args
@OLDARGV = @ARGV;
while(@ARGV > 0) {
	local $a = shift(@ARGV);
	if ($a eq "--id") {
		$id = shift(@ARGV);
		}
	elsif ($a eq "--dest") {
		$dest = shift(@ARGV);
		}
	elsif ($a eq "--multiline") {
		$multiline = 1;
		}
	elsif ($a eq "--help") {
		&usage();
		}
	else {
		&usage("Unknown parameter $a");
		}
	}

# Get the backup to remove
if ($id) {
	($sched) = grep { $_->{'id'} eq $id } &list_scheduled_backups();
	$sched || &usage("No backup with ID $id exists");
	}
elsif ($dest) {
	($sched) = grep { &indexof($dest, &get_scheduled_backup_dests($_)) >= 0 } &list_scheduled_backups();
	$sched || &usage("No backup with destination $dest exists");
	}
else {
	&usage("Missing --id or --dest parameters");
	}
&delete_scheduled_backup($sched);
print "Scheduled backup deleted with ID $sched->{'id'}\n";

&virtualmin_api_log(\@OLDARGV);

sub usage
{
if ($_[0]) {
	print $_[0],"\n\n";
	}
print "Delete a scheduled backup for one or more virtual servers.\n";
print "\n";
print "virtualmin delete-scheduled-backup [--id number]\n";
print "                                   [--dest path]\n";
exit(1);
}