Server IP : 195.201.23.43 / Your IP : 3.129.194.144 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/fsdump/ |
Upload File : |
#!/usr/bin/perl # backup.pl # Perform a backup and send the results to someone $no_acl_check++; require './fsdump-lib.pl'; $dump = &get_dump($ARGV[0]); $dump->{'id'} || die "Dump $ARGV[0] does not exist!"; # Check if this backup is already running &foreign_require("proc", "proc-lib.pl"); @procs = &proc::list_processes(); @running = &running_dumps(\@procs); ($running) = grep { $_->{'id'} eq $dump->{'id'} && $_->{'pid'} != $$ } @running; $sfile = "$module_config_directory/$dump->{'id'}.$$.status"; if ($running) { # Already running! Do nothing .. $ok = 0; $out = &text('email_already', $running->{'pid'})."\n"; } else { # Update status file %status = ( 'status' => 'running', 'pid' => $$, 'start' => time() ); &write_file($sfile, \%status); if ($dump->{'email'}) { # Save output for mailing $temp = &transname(); open(OUT, ">$temp"); } else { # Throw output away open(OUT, ">/dev/null"); } # Create tape change wrapper &create_wrappers(); $bok = &execute_before($dump, OUT, 0); if (!$bok && !$dump->{'beforefok'}) { # Before command failed! print OUT "\n$text{'email_ebefore'}\n"; $status{'status'} = 'failed'; } else { # Do the backup $now = time(); $ok = &execute_dump($dump, OUT, 0, 1, $now); # Re-update the status file if ($ok) { # Worked .. but verify if asked if ($dump->{'reverify'}) { print OUT "\n$text{'email_verify'}\n"; $ok = &verify_dump($dump, OUT, 0, 1, $now); } if ($ok) { $status{'status'} = 'complete'; } else { $status{'status'} = 'verifyfailed'; } } else { $status{'status'} = 'failed'; } } $status{'end'} = time(); &write_file($sfile, \%status); if ($status{'status'} eq 'complete' || $dump->{'afteraok'}) { # Execute the post-backup script $dump{'status'} = $status{'status'}; $bok = &execute_after($dump, OUT, 0); if (!$bok && !$dump->{'afterfok'}) { print OUT "\n$text{'email_eafter'}\n"; $status{'status'} = 'failed'; $ok = 0; } } close(OUT); if ($temp) { # Read output open(OUT, "<".$temp); while(<OUT>) { s/\r//g; $out .= $_; } close(OUT); unlink($temp); } } if ($out && $dump->{'email'} && &foreign_check("mailboxes")) { # Construct the email &foreign_require("mailboxes", "mailboxes-lib.pl"); $host = &get_system_hostname(); @dirs = &dump_directories($dump); $dirs = join(", ", @dirs); %hash = ( %$dirs, 'dirs' => $dirs ); local $subject = &substitute_template($dump->{'subject'}, \%hash) || &text('email_subject', $dirs, $host); local $data = &text('email_subject', $dirs, $host)."\n\n"; $data .= $out; $data .= "\n"; if ($ok) { $data .= $text{'email_ok'}."\n"; } else { $data .= $text{'email_failed'}."\n"; } # Send the email if (!$ok || !$config{'error_email'}) { # Only send email upon failure, or it requested always &mailboxes::send_text_mail(&mailboxes::get_from_address(), $dump->{'email'}, undef, $subject, $data, $config{'smtp_server'}); } } # Check for any dumps scheduled to run after this one foreach $follow (&list_dumps()) { if ($follow->{'follow'} eq $dump->{'id'} && $follow->{'enabled'} == 2) { system("$cron_cmd $follow->{'id'}"); } }Private