"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/BackupPC/CGI/Archive.pm" between
BackupPC-4.3.2.tar.gz and BackupPC-4.4.0.tar.gz

About: BackupPC is a high-performance, enterprise-grade system for backing up Linux and WinXX PCs and laptops to a server’s disk (http/cgi user interface).

Archive.pm  (BackupPC-4.3.2):Archive.pm  (BackupPC-4.4.0)
skipping to change at line 30 skipping to change at line 30
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
#======================================================================== #========================================================================
# #
# Version 4.3.2, released 17 Feb 2020. # Version 4.4.0, released 20 Jun 2020.
# #
# See http://backuppc.sourceforge.net. # See http://backuppc.sourceforge.net.
# #
#======================================================================== #========================================================================
package BackupPC::CGI::Archive; package BackupPC::CGI::Archive;
use strict; use strict;
use BackupPC::CGI::Lib qw(:all); use BackupPC::CGI::Lib qw(:all);
use Data::Dumper; use Data::Dumper;
use File::Path; use File::Path;
sub action sub action
{ {
my $archHost = $In{host}; my $archHost = $In{host};
my $Privileged = CheckPermission(); my $Privileged = CheckPermission();
if ( !$Privileged ) { if ( !$Privileged ) {
ErrorExit($Lang->{Only_privileged_users_can_archive} ); ErrorExit($Lang->{Only_privileged_users_can_archive});
} }
if ( $In{type} == 0 ) { if ( $In{type} == 0 ) {
my($fullTot, $fullSizeTot, $incrTot, $incrSizeTot, $str, my(
$strNone, $strGood, $hostCntGood, $hostCntNone, $checkBoxCnt, $fullTot, $fullSizeTot, $incrTot, $incrSizeTot, $str, $strNone,
$backupnumber); $strGood, $hostCntGood, $hostCntNone, $checkBoxCnt, $backupnumber
);
$hostCntGood = $hostCntNone = $checkBoxCnt = $fullSizeTot = 0; $hostCntGood = $hostCntNone = $checkBoxCnt = $fullSizeTot = 0;
GetStatusInfo("hosts"); GetStatusInfo("hosts");
foreach my $host ( sort(keys(%Status)) ) { foreach my $host ( sort(keys(%Status)) ) {
my($fullDur, $incrCnt, $fullSize, $fullRate); my($fullDur, $incrCnt, $fullSize, $fullRate);
my @Backups = $bpc->BackupInfoRead($host); my @Backups = $bpc->BackupInfoRead($host);
my $fullCnt = $incrCnt = 0; my $fullCnt = $incrCnt = 0;
for ( my $i = 0 ; $i < @Backups ; $i++ ) { for ( my $i = 0 ; $i < @Backups ; $i++ ) {
if ( $Backups[$i]{type} eq "full" ) { if ( $Backups[$i]{type} eq "full" ) {
$fullSize = $Backups[$i]{size} / (1024 * 1024); $fullSize = $Backups[$i]{size} / (1024 * 1024);
$incrSizeTot = 0; $incrSizeTot = 0;
} else { } else {
$incrSizeTot = $Backups[$i]{size} / (1024 * 1024); $incrSizeTot = $Backups[$i]{size} / (1024 * 1024);
} }
$backupnumber = $Backups[$i]{num}; $backupnumber = $Backups[$i]{num};
} }
$fullSizeTot += $fullSize + $incrSizeTot; $fullSizeTot += $fullSize + $incrSizeTot;
$fullSize = sprintf("%.2f", ($fullSize + $incrSizeTot) / 1024); $fullSize = sprintf("%.2f", ($fullSize + $incrSizeTot) / 1024);
$str = <<EOF; $str = <<EOF;
<tr> <tr>
<td class="border"><input type="hidden" name="backup$checkBoxCnt" value="$backup number"><input type="checkbox" name="fcb$checkBoxCnt" value="$host">&nbsp;${Host Link($host)} </td> <td class="border"><input type="hidden" name="backup$checkBoxCnt" value="$backup number"><input type="checkbox" name="fcb$checkBoxCnt" value="$host">&nbsp;${Host Link($host)} </td>
<td align="center" class="border"> ${UserLink($Hosts->{$host}{user})} </td> <td align="center" class="border"> ${UserLink($Hosts->{$host}{user})} </td>
<td align="center" class="border"> $fullSize </td> <td align="center" class="border"> $fullSize </td>
EOF EOF
$checkBoxCnt++; $checkBoxCnt++;
if ( @Backups == 0 ) { if ( @Backups == 0 ) {
$hostCntNone++; $hostCntNone++;
$strNone .= $str; $strNone .= $str;
} else { } else {
$hostCntGood++; $hostCntGood++;
$strGood .= $str; $strGood .= $str;
} }
} }
$fullSizeTot = sprintf("%.2f", $fullSizeTot / 1024); $fullSizeTot = sprintf("%.2f", $fullSizeTot / 1024);
my $now = timeStamp2(time); my $now = timeStamp2(time);
my $checkAllHosts = $Lang->{checkAllHosts}; my $checkAllHosts = $Lang->{checkAllHosts};
$strGood .= <<EOF; $strGood .= <<EOF;
<input type="hidden" name="archivehost" value="$In{'archivehost'}"> <input type="hidden" name="archivehost" value="$In{'archivehost'}">
EOF EOF
my $content = eval("qq{$Lang->{BackupPC_Archive}}"); my $content = eval("qq{$Lang->{BackupPC_Archive}}");
Header(eval("qq{$Lang->{BackupPC__Archive}}"), $content, 1); Header(eval("qq{$Lang->{BackupPC__Archive}}"), $content, 1);
Trailer(); Trailer();
} else { } else {
my(@HostList, @BackupList, $HostListStr, $hiddenStr, $pathHdr, my(@HostList, @BackupList, $HostListStr, $hiddenStr, $pathHdr, $badFileC
$badFileCnt, $reply, $str); nt, $reply, $str);
# #
# Pick up the archive host's config file # Pick up the archive host's config file
# #
$bpc->ConfigRead($archHost); $bpc->ConfigRead($archHost);
%Conf = $bpc->Conf(); %Conf = $bpc->Conf();
my $args = { my $args = {
SplitPath => $Conf{SplitPath}, SplitPath => $Conf{SplitPath},
ParPath => $Conf{ParPath}, ParPath => $Conf{ParPath},
skipping to change at line 125 skipping to change at line 125
ArchiveComp => $Conf{ArchiveComp}, ArchiveComp => $Conf{ArchiveComp},
ArchivePar => $Conf{ArchivePar}, ArchivePar => $Conf{ArchivePar},
ArchiveSplit => $Conf{ArchiveSplit}, ArchiveSplit => $Conf{ArchiveSplit},
topDir => $bpc->{TopDir}, topDir => $bpc->{TopDir},
}; };
ServerConnect(); ServerConnect();
for ( my $i = 0 ; $i < $In{fcbMax} ; $i++ ) { for ( my $i = 0 ; $i < $In{fcbMax} ; $i++ ) {
next if ( !defined($In{"fcb$i"}) ); next if ( !defined($In{"fcb$i"}) );
my $name = $In{"fcb$i"}; my $name = $In{"fcb$i"};
my $backupno = $In{"backup$i"}; my $backupno = $In{"backup$i"};
push(@HostList, $name); push(@HostList, $name);
push(@BackupList, $backupno); push(@BackupList, $backupno);
$hiddenStr .= <<EOF; $hiddenStr .= <<EOF;
<input type="hidden" name="fcb$i" value="$In{'fcb' . $i}"> <input type="hidden" name="fcb$i" value="$In{'fcb' . $i}">
<input type="hidden" name="backup$i" value="$In{'backup' . $i}"> <input type="hidden" name="backup$i" value="$In{'backup' . $i}">
EOF EOF
$HostListStr .= <<EOF; $HostListStr .= <<EOF;
<li> ${EscHTML($name)} <li> ${EscHTML($name)}
EOF EOF
} }
$hiddenStr .= <<EOF; $hiddenStr .= <<EOF;
<input type="hidden" name="archivehost" value="$In{'archivehost'}"> <input type="hidden" name="archivehost" value="$In{'archivehost'}">
EOF EOF
$hiddenStr .= "<input type=\"hidden\" name=\"fcbMax\" value=\"$In{fcbMax }\">\n"; $hiddenStr .= "<input type=\"hidden\" name=\"fcbMax\" value=\"$In{fcbMax }\">\n";
if ( @HostList == 0 ) { if ( @HostList == 0 ) {
ErrorExit($Lang->{You_haven_t_selected_any_hosts}); ErrorExit($Lang->{You_haven_t_selected_any_hosts});
} }
my ($ArchiveDest, $ArchiveCompNone, $ArchiveCompGzip, my($ArchiveDest, $ArchiveCompNone, $ArchiveCompGzip, $ArchiveCompBzip2,
$ArchiveCompBzip2, $ArchivePar, $ArchiveSplit); $ArchivePar, $ArchiveSplit);
$ArchiveDest = $Conf{ArchiveDest}; $ArchiveDest = $Conf{ArchiveDest};
if ( $Conf{ArchiveComp} eq "none" ) { if ( $Conf{ArchiveComp} eq "none" ) {
$ArchiveCompNone = "checked"; $ArchiveCompNone = "checked";
} else { } else {
$ArchiveCompNone = ""; $ArchiveCompNone = "";
} }
if ( $Conf{ArchiveComp} eq "gzip" ) { if ( $Conf{ArchiveComp} eq "gzip" ) {
$ArchiveCompGzip = "checked"; $ArchiveCompGzip = "checked";
} else { } else {
$ArchiveCompGzip = ""; $ArchiveCompGzip = "";
} }
if ( $Conf{ArchiveComp} eq "bzip2" ) { if ( $Conf{ArchiveComp} eq "bzip2" ) {
$ArchiveCompBzip2 = "checked"; $ArchiveCompBzip2 = "checked";
} else { } else {
$ArchiveCompBzip2 = ""; $ArchiveCompBzip2 = "";
} }
$ArchivePar = $Conf{ArchivePar}; $ArchivePar = $Conf{ArchivePar};
$ArchiveSplit = $Conf{ArchiveSplit}; $ArchiveSplit = $Conf{ArchiveSplit};
if ( $In{type} == 1 ) { if ( $In{type} == 1 ) {
# #
# Tell the user what options they have # Tell the user what options they have
# #
my $paramStr = ""; my $paramStr = "";
if ( $Conf{ArchiveClientCmd} =~ /\$archiveloc\b/ ) { if ( $Conf{ArchiveClientCmd} =~ /\$archiveloc\b/ ) {
$paramStr .= eval("qq{$Lang->{BackupPC_Archive2_location}}"); $paramStr .= eval("qq{$Lang->{BackupPC_Archive2_location}}");
} }
if ( $Conf{ArchiveClientCmd} =~ /\$compression\b/ ) { if ( $Conf{ArchiveClientCmd} =~ /\$compression\b/ ) {
$paramStr .= eval("qq{$Lang->{BackupPC_Archive2_compression}}"); $paramStr .= eval("qq{$Lang->{BackupPC_Archive2_compression}}");
} }
if ( $Conf{ArchiveClientCmd} =~ /\$parfile\b/ if ( $Conf{ArchiveClientCmd} =~ /\$parfile\b/ && -x $Conf{ParPath} )
&& -x $Conf{ParPath} ) { {
$paramStr .= eval("qq{$Lang->{BackupPC_Archive2_parity}}"); $paramStr .= eval("qq{$Lang->{BackupPC_Archive2_parity}}");
} }
if ( $Conf{ArchiveClientCmd} =~ /\$splitsize\b/ if ( $Conf{ArchiveClientCmd} =~ /\$splitsize\b/ && -x $Conf{SplitPat
&& -x $Conf{SplitPath} ) { h} ) {
$paramStr .= eval("qq{$Lang->{BackupPC_Archive2_split}}"); $paramStr .= eval("qq{$Lang->{BackupPC_Archive2_split}}");
} }
my $content = eval("qq{$Lang->{BackupPC_Archive2}}"); my $content = eval("qq{$Lang->{BackupPC_Archive2}}");
Header(eval("qq{$Lang->{BackupPC__Archive}}"), $content, 1); Header(eval("qq{$Lang->{BackupPC__Archive}}"), $content, 1);
Trailer(); Trailer();
} elsif ( $In{type} == 2 ) { } elsif ( $In{type} == 2 ) {
my $reqFileName; my $reqFileName;
my $archivehost = $1 if ( $In{archivehost} =~ /(.+)/ ); my $archivehost = $1 if ( $In{archivehost} =~ /(.+)/ );
for ( my $i = 0 ; ; $i++ ) { for ( my $i = 0 ; ; $i++ ) {
$reqFileName = "archiveReq.$$.$i"; $reqFileName = "archiveReq.$$.$i";
last if ( !-f "$TopDir/pc/$archivehost/$reqFileName" ); last if ( !-f "$TopDir/pc/$archivehost/$reqFileName" );
} }
my($compname, $compext); my($compname, $compext);
if ( $In{compression} == 2 ) { # bzip2 compression if ( $In{compression} == 2 ) { # bzip2 compression
$compname = $Conf{Bzip2Path}; $compname = $Conf{Bzip2Path};
$compext = '.bz2'; $compext = '.bz2';
} elsif ( $In{compression} == 1 ) { # gzip compression } elsif ( $In{compression} == 1 ) { # gzip compression
$compname = $Conf{GzipPath}; $compname = $Conf{GzipPath};
$compext = '.gz'; $compext = '.gz';
} else { # No Compression } else { # No Compression
$compname = $Conf{CatPath}; $compname = $Conf{CatPath};
$compext = '.raw'; $compext = '.raw';
} }
my $fullsplitsize = $In{splitsize} . '000000'; my $fullsplitsize = $In{splitsize} . '000000';
my %ArchiveReq = ( my %ArchiveReq = (
# parameters for the archive # parameters for the archive
archiveloc => $In{archive_device}, archiveloc => $In{archive_device},
archtype => $In{archive_type}, archtype => $In{archive_type},
compression => $compname, compression => $compname,
compext => $compext, compext => $compext,
parfile => $In{par}, parfile => $In{par},
splitsize => $fullsplitsize, splitsize => $fullsplitsize,
host => $archivehost, host => $archivehost,
# list of hosts to restore # list of hosts to restore
HostList => \@HostList, HostList => \@HostList,
BackupList => \@BackupList, BackupList => \@BackupList,
# other info # other info
user => $User, user => $User,
reqTime => time, reqTime => time,
); );
my($archive) = Data::Dumper->new( my($archive) = Data::Dumper->new([\%ArchiveReq], [qw(*ArchiveReq)]);
[ \%ArchiveReq],
[qw(*ArchiveReq)]);
$archive->Indent(1); $archive->Indent(1);
eval { mkpath("$TopDir/pc/$archivehost", 0, 0777) } eval { mkpath("$TopDir/pc/$archivehost", 0, 0777) }
if ( !-d "$TopDir/pc/$archivehost" ); if ( !-d "$TopDir/pc/$archivehost" );
my $openPath = "$TopDir/pc/$archivehost/$reqFileName"; my $openPath = "$TopDir/pc/$archivehost/$reqFileName";
if ( open(REQ, ">", $openPath) ) { if ( open(REQ, ">", $openPath) ) {
binmode(REQ); binmode(REQ);
print(REQ $archive->Dump); print(REQ $archive->Dump);
close(REQ); close(REQ);
} else { } else {
ErrorExit(eval("qq{$Lang->{Can_t_open_create__openPath}}")); ErrorExit(eval("qq{$Lang->{Can_t_open_create__openPath}}"));
} }
$reply = $bpc->ServerMesg("archive $User $archivehost $reqFileName") ; $reply = $bpc->ServerMesg("archive $User $archivehost $reqFileName") ;
$str = eval("qq{$Lang->{Archive_requested}}"); $str = eval("qq{$Lang->{Archive_requested}}");
my $content = eval("qq{$Lang->{BackupPC_Archive_Reply_from_server}}" ); my $content = eval("qq{$Lang->{BackupPC_Archive_Reply_from_server}}" );
Header(eval("qq{$Lang->{BackupPC__Archive}}"), $content, 1); Header(eval("qq{$Lang->{BackupPC__Archive}}"), $content, 1);
Trailer(); Trailer();
} }
} }
} }
1; 1;
 End of changes. 29 change blocks. 
44 lines changed or deleted 44 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)