Server IP : 195.201.23.43 / Your IP : 3.147.84.210 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : 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, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/virtual-server/ |
Upload File : |
#!/usr/bin/perl =head1 list-scheduled-backups.pl Outputs a list of scheduled backups By default, this program displays a table of all scheduled backups on the system. You can limit it to those owned by some virtual server with the C<--domain> or C<--user> flag, or to a reseller with the C<--reseller> flag. These must be followed by a domain name, administration username or reseller login respectively. To switch to a more detailed and parseable output format, add the C<--multiline> flag to the command line. To show only scheduled backup IDs, use the C<--id-only> flag. =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/list-scheduled-backups.pl"; require './virtual-server-lib.pl'; $< == 0 || die "list-scheduled-backups.pl must be run as root"; } # Parse command-line args while(@ARGV > 0) { local $a = shift(@ARGV); if ($a eq "--domain") { $domain = shift(@ARGV); } elsif ($a eq "--reseller") { $reseller = shift(@ARGV); } elsif ($a eq "--user") { $user = shift(@ARGV); } elsif ($a eq "--multiline") { $multi = 1; } elsif ($a eq "--id-only") { $idonly = 1; } elsif ($a eq "--help") { &usage(); } else { &usage("Unknown parameter $a"); } } # Get them all, then limit by domain @scheds = &list_scheduled_backups(); if ($domain) { # By top-level domain $d = &get_domain_by("dom", $domain); $d || &usage("No domain named $domain exists"); $d->{'parent'} && &usage("--domain must be followed by a top-level domain name"); @scheds = grep { $_->{'owner'} eq $d->{'id'} } @scheds; } elsif ($user) { # By domain owner $d = &get_domain_by_user($user); $d || &usage("No domain owned by $user exists"); @scheds = grep { $_->{'owner'} eq $d->{'id'} } @scheds; } elsif ($reseller) { # By reseller owner @scheds = grep { $_->{'owner'} eq $reseller } @scheds; } if ($multi) { # Show all details %running = map { $_->{'id'}, $_ } &list_running_backups(); foreach my $s (@scheds) { print "$s->{'id'}\n"; print " Domains: ",&make_nice_dnames($s),"\n"; print " Include sub-servers: ", $s->{'parent'} ? "Yes" : "No","\n"; if ($s->{'virtualmin'}) { print " Virtualmin configs: $s->{'virtualmin'}\n"; } @dests = get_scheduled_backup_dests($s); @purges = &get_scheduled_backup_purges($s); for(my $i=0; $i<@dests; $i++) { print " Destination: $dests[$i]\n"; print " Delete old backups after: ", ($purges[$i] ? "$purges[$i] days" : "Never"),"\n"; } if ($s->{'key'} && defined(&get_backup_key)) { $key = &get_backup_key($s->{'key'}); print " Encryption key: ", $key->{'desc'},"\n"; print " Encryption key ID: ", $key->{'id'},"\n"; } if ($s->{'owner'}) { my $o = &get_domain($s->{'owner'}); print " Owner: $o->{'dom'}\n"; } print " Features: ", $s->{'feature_all'} ? "All" : $s->{'features'},"\n"; print " Format: ", ($s->{'fmt'} == 0 ? "Single archive file" : $s->{'fmt'} == 1 ? "One file per server (old format)" : "One file per server"),"\n"; print " Differential: ",$s->{'increment'} ? "Yes" : "No","\n"; print " Enabled: ",$s->{'enabled'} ? "Yes" : "No","\n"; if ($s->{'special'}) { print " Cron schedule: $s->{'special'}\n"; } elsif ($s->{'mins'}) { print " Cron schedule: ", join(" ", $s->{'mins'}, $s->{'hours'}, $s->{'days'}, $s->{'months'}, $s->{'weekdays'}),"\n"; } if ($s->{'email'}) { print " Send email to: $s->{'email'}\n"; } print " Send email: ", $s->{'email_err'} ? "Only on failure" : "Always","\n"; print " Notify domain owners: ", $s->{'email_doms'} ? "Yes" : "No","\n"; $r = $running{$s->{'id'}}; if ($r) { print " Running: Yes\n"; print " Started at: ",&make_date($r->{'started'}),"\n"; print " Process ID: ",$r->{'pid'},"\n"; } else { print " Running: No\n"; } } } elsif ($idonly) { # Just show IDs foreach my $s (@scheds) { print $s->{'id'},"\n"; } } else { # Just show one per line $fmt = "%-22.22s %-40.40s %-15.15s\n"; printf $fmt, "Domains", "Destination", "Schedule"; printf $fmt, ("-" x 22), ("-" x 40), ("-" x 15); foreach my $s (@scheds) { printf $fmt, &make_nice_dnames($s), &html_tags_to_text( &nice_backup_url($s->{'dest'}, 1)), !$s->{'enabled'} ? "Disabled" : $s->{'special'} ? $s->{'special'} : join(" ", $s->{'mins'}, $s->{'hours'}, $s->{'days'}, $s->{'months'}, $s->{'weekdays'}); } } sub usage { print "$_[0]\n\n" if ($_[0]); print "Lists some or all scheduled Virtualmin backups.\n"; print "\n"; print "virtualmin list-scheduled-backups [--domain domain.name |\n"; print " --user name |\n"; print " --reseller name]\n"; print " [--multiline | --id-only]\n"; exit(1); } sub make_nice_dnames { local ($s) = @_; local @dnames = ( ); foreach my $did (split(/\s+/, $s->{'doms'})) { $d = &get_domain($did); push(@dnames, $d->{'dom'}) if ($d); } my $dnames = join(" ", @dnames); return $s->{'all'} == 1 ? "All" : $s->{'all'} == 2 ? "Except ".$dnames : $dnames ? $dnames : "None"; }Private