Chinaunix首页 | 论坛 | 博客
  • 博客访问: 267581
  • 博文数量: 44
  • 博客积分: 1431
  • 博客等级: 上尉
  • 技术积分: 558
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-24 12:53
文章分类
文章存档

2012年(1)

2011年(28)

2010年(15)

分类: LINUX

2011-09-02 09:51:02

完整备份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);


阅读(1580) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~