# export LANG="zh_CN.GB2312" //文件名有中文的时候需要设置变量 # svn import /data/file/ file:///data/svn/project/file --message "init" # svn import /data/file/ svn:///data/svn/project/file --message "init" //两条命令是一样的
五、SVN的备份和还原(两种备份方式)
1、hotcopy备份方式: # svnadmin hotcopy /data/svn/project /data/bakup/`date +/%y%m%d`/ --clean-logs //用svnadmin整体备份/data/svn/project到/data/bakup/目录里并且以时间命名 2、dump备份方式: # svnadmin dump /data/svn/project > /data/beifen/`date +/%Y%m%d`.bak //推荐此方法备份,下面模拟用的就是dump的方式
六、模拟服务器奔溃(在有备份文件的情况下,恢复到新服务器)
# rm -rf /data/svn/* # ps -ef |grep svn # kill -9 26221 # svnadmin create /data/svn/ceshi # export LANG=en_US # svnadmin load /data/svn/ceshi < /data/20150906 # cat /data/passwd >> /data/svn/ceshi/conf/passwd
[users] admin:uyvcrbGbdBPuk
# vim /data/svn/ceshi/conf/authz[groups] [/] admin = rw * =
# vim /data/svn/ceshi/conf/svnserve.conf[general] anon-access = none auth-access = write password-db = /data/svn/ceshi/conf/passwd authz-db = /data/svn/ceshi/conf/authz
# vim /etc/httpd/conf/httpd.conf
<Location /ceshi> DAV svn SVNPath /data/svn/ceshi/ AuthType Basic AuthName "svn for ceshi" AuthUserFile /data/svn/ceshi/conf/passwd AuthzSVNAccessFile /data/svn/ceshi/conf/authz Satisfy all Require valid-user </Location>
# service httpd restart
# svnserve -d -r /data/svn
测试是否成功恢复
七、自动全量备份脚本
# vim svn.pl
#!/usr/bin/perl -w my $svn_repos="/data/svn/project"; my $backup_dir="/data/backup/svn/"; my $next_backup_file = "svn".`date +%Y%m%d`; $youngest=`svnlook youngest $svn_repos`; chomp $youngest; print "Backing up to revision $youngest"; 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`;
删除三天前的备份文件
# vim svn-Timing-delete.sh
find /data/backup/svn/ -type f -mtime +3 -exec rm '{}' \;
添加到计划任务
# crontab -e
30 22 * * * perl /data/svn/svn.pl 00 23 * * * bash /data/svn/svn-Timing-delete.sh
Ubuntu 14.04 下搭建SVN服务器 SVN://
CentOS 6.2 SVN搭建 (YUM安装)
Windows下SVN服务器搭建和使用 + 客户端重新设置密码