注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

无线时代辐射无穷

抓紧生宝宝,小心辐射

 
 
 

日志

 
 

subversion备份之svnadmin dump备份工具  

2011-03-24 22:54:44|  分类: 版本控制 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

How to upgrade v2 to v3 FSFS subversion filesystem

一般由于Linux默认安装了subversion 1.4.x 而如果手工安装subversion1.6.x 结果没有注意到PATH设置则会导致建库用的是1.4.x中的svnadmin 而客户端可能用的subclipse或乌龟svn 可能在版本合并的时候产生v2 to v3的FSFS 文件系统问题。

You didn't specify the version of Subversion that your server is running. But based on the message you provided in the question, it's probably a 1.4.x version or older. I don't remember if there was an upgrade command provided or not for conversion from 1.4.x to 1.5.x, but the sure file way to get your repository from version 2 to version is to a dump and load. But that doesn't matter much, you'll want to install 1.6.x anyway to go with the latest. So, here are the steps you need to do:
Upgrade to Subversion 1.6.x if haven't already
Dump your existing repository using svnadmin dump > file
Create a new repo, call it _new
Load your new repo with the dump of the old using svnadmin load  < file
Copy the uuid file from the old repository to the new repository
rename the old repository to _old
rename the new repository to
That should get you taken care of and the uuid file will keep your clients from freaking out. Do an svn update to be sure though.

 

下面是subversion官方推荐的备份恢复方式:

关闭所有运行的进程,并确认没有程序在访问存储库(如 httpd、svnserve 或本地用户在直接访问)。
备份svn存储库

#压缩备份
svnadmin dump /home/workhome/svn/repository | gzip > ~/repository-backup.gz
#不压缩备份
svnadmin dump /home/workhome/svn/repository > ~/repository-backup.svn

恢复svn存储库

#建立新的svn存储库
svnadmin create /home/workhome/svn/newrepository
#确认成功与否
ls -l /home/workhome/svn/newrepository
#导入存储库数据
svnadmin load /home/workhome/svn/newrepository < ~/repository-backup.svn

或者采用一定的备份策略:
1)定义备份策略:
备份频度:每周六进行一次全量备份,每周日到周五进行增量备份
备份地点:备份存储路径到/home/backup/svn/
备份命名:全量备份文件名为:weekly_fully_backup.yymmdd,增量备份文件命名为:daily-incremental-backup.yymmdd
备份时间:每晚21点开始
备份检查:每月末进行svnadmin load恢复试验。
2)建立全量备份脚本:
在~/下建立一个perl脚本文件,名为weekly_backup.pl,执行全量备份,并压缩备份文件,代码如下(本代码只针对一个库的备份,如果是多个库请做相应改动):
#!/usr/bin/perl -w
my $svn_repos="/home/svn/repos/project1";
my $backup_dir="/home/backup/svn/";
my $next_backup_file = "weekly_fully_backup.".`date +%Y%m%d`;
$youngest=`svnlook youngest $svn_repos`;
chomp $youngest;
print "Backing up to revision $youngestn";
my $svnadmin_cmd="svnadmin dump——revision $youngest $svn_repos >$backup_dir/$next_backup_file";
`$svnadmin_cmd`;
open(LOG,">$backup_dir/last_backed_up"); #记录备份的版本号
print LOG $youngest;
close LOG;
#如果想节约空间,则再执行下面的压缩脚本
print "Compressing dump file...n";
print `gzip -9 $backup_dir/$next_backup_file`;
3)建立增量备份脚本:
在全量备份的基础上,进行增量备份:在~/下建立一个perl脚本文件,名为:daily_backup.pl,代码如下:
#!/usr/bin/perl -w
my $svn_repos="/home/svn/repos/project1";
my $backup_dir="/home/backup/svn/";
my $next_backup_file = "daily_incremental_backup.".`date +%Y%m%d`;
open(IN,"$backup_dir/last_backed_up");
$previous_youngest = <IN>;
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;
}
my $first_rev = $previous_youngest + 1;
print "Backing up revisions $youngest ...n";
my $svnadmin_cmd = "svnadmin dump——incremental ——revision $first_rev $youngest $svn_repos > $backup_dir/$next_backup_file";
`$svnadmin_cmd`;
open(LOG,">$backup_dir/last_backed_up"); #记录备份的版本号
print LOG $youngest;
close LOG;
#如果想节约空间,则再执行下面的压缩脚本
print "Compressing dump file...n";
print `gzip -g $backup_dir/$next_backup_file`;
4)配置/etc/crontab文件
配置 /etc/crontab 文件,指定每周六执行weekly_backup.pl,指定周一到周五执行daily_backup.pl;
具体步骤俺就不啰嗦了.
5)备份恢复检查
在月底恢复检查中或者在灾难来临时,请按照如下步骤进行恢复:恢复顺序从低版本逐个恢复到高版本;即,先恢复最近的一次完整备份 weekly_full_backup.071201(举例),然后恢复紧挨着这个文件的增量备份 daily_incremental_backup.071202,再恢复后一天的备份071203,依次类推。如下:
user1>mkdir newrepos
user1>svnadmin create newrepos
user1>svnadmin load newrepos < weekly_full_backup.071201
user1>svnadmin load newrepos < daily_incremental_backup.071202
user1>svnadmin load newrepos < daily_incremental_backup.071203
....
如果备份时采用了gzip进行压缩,恢复时可将解压缩和恢复命令合并,简单写成:
user1>zcat weekly_full_backup.071201 | svnadmin load newrepos
user1>zcat daily_incremental_backup.071202 | svnadmin load newrepos
...

  评论这张
 
阅读(4879)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017