完整备份perl脚本
svn_fully_backup.pl
#!/usr/bin/perl -w
$svn_repos = "/opt/svndata/reservation";
$backups_dir = "/home/backup/svn";
my($sec,$min,$hou,$day, $mon, $year) = localtime();
$mon++;$year+=1900;
my $datetime=sprintf("%04u%02u%02u", $year, $mon, $day);
$next_backup_file = "fully_bakup_on_"."$datetime";
$youngest = `svnlook youngest $svn_repos`;
chomp $youngest;
print "Backing up to revision $youngest\n";
$svnadmin_cmd = "svnadmin dump --revision 0:$youngest " . "$svn_repos > $backups_dir/$next_backup_file";
`$svnadmin_cmd`;
open(FILE, ">/home/backup/svn/fully_backup_log");
syswrite(FILE,"The latest version is $youngest");
close(FILE);
增量备份perl脚本
svn_incremental_backup.pl
#!/usr/bin/perl -w
$svn_repos="/opt/svndata/reservation";
$backup_dir="/home/backup/svn";
my($sec,$min,$hou,$day, $mon, $year) = localtime();
$mon++;$year+=1900;
my $datetime=sprintf("%04u%02u%02u", $year, $mon, $day);
$next_backup_file = "incremental_backup_on_"."$datetime";
open(IN,"/home/backup/svn/incremental_backup_log");
$previous_youngest = ;
chomp $previous_youngest;
close(IN);
$youngest=`svnlook youngest $svn_repos`;
chomp $youngest;
if ($youngest eq $previous_youngest)
{
print "No new revisions to backup.\n";
exit 0;
}
$first_rev = $previous_youngest + 1;
print "Backing up revisions $youngest ...n";
$svnadmin_cmd = "svnadmin dump --incremental --revision $first_rev:$youngest $svn_repos > $backup_dir/$next_backup_file";
`$svnadmin_cmd`;
open(FILE, ">/home/backup/svn/incremental_backup_log");
syswrite(FILE,"The latest version is $youngest");
close(FILE);
阅读(1600) | 评论(0) | 转发(0) |