windows SVN 仓库备份策略
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SVN repository backup strategies
提问by Robert Dean
I'm new to SVN and I'd like to know what methods are available for backing up repositories in a Windows environment?
我是 SVN 的新手,我想知道在 Windows 环境中备份存储库的方法有哪些?
采纳答案by Nicolai Reuschling
You could use something like (Linux):
你可以使用类似(Linux)的东西:
svnadmin dump repositorypath | gzip > backupname.svn.gz
Since Windows does not support GZip it is just:
由于 Windows 不支持 GZip,它只是:
svnadmin dump repositorypath > backupname.svn
回答by Duncan Smart
We use svnadmin hotcopy, e.g.:
我们使用 svnadmin hotcopy,例如:
svnadmin hotcopy C:\svn\repo D:\backups\svn\repo
As per the book:
根据书中:
You can run this command at any time and make a safe copy of the repository, regardless of whether other processes are using the repository.
您可以随时运行此命令并制作存储库的安全副本,无论其他进程是否正在使用存储库。
You can of course ZIP (preferably 7-Zip) the backup copy. IMHO It's the most straightforward of the backup options: in case of disaster there's little to do other than unzip it back into position.
您当然可以压缩(最好是 7-Zip)备份副本。恕我直言,这是最直接的备份选项:在发生灾难时,除了将其解压缩回原位之外别无他法。
回答by Kevin Dente
There's a hotbackup.py script available on the Subversion web site that's quite handy for automating backups.
Subversion 网站上有一个 hotbackup.py 脚本,它对于自动备份非常方便。
http://svn.apache.org/repos/asf/subversion/trunk/tools/backup/hot-backup.py.in
http://svn.apache.org/repos/asf/subversion/trunk/tools/backup/hot-backup.py.in
回答by Kevin Dente
Here is a Perl script that will:
这是一个 Perl 脚本,它将:
- Backup the repo
- Copy it to another server via SCP
- Retrieve the backup
- Create a test repository from the backup
- Do a test checkout
- Email you with any errors (via cron)
- 备份 repo
- 通过 SCP 将其复制到另一台服务器
- 检索备份
- 从备份创建测试存储库
- 做一个测试结帐
- 有任何错误通过电子邮件发送给您(通过 cron)
The script:
剧本:
my $svn_repo = "/var/svn";
my $bkup_dir = "/home/backup_user/backups";
my $bkup_file = "my_backup-";
my $tmp_dir = "/home/backup_user/tmp";
my $bkup_svr = "my.backup.com";
my $bkup_svr_login = "backup";
$bkup_file = $bkup_file . `date +%Y%m%d-%H%M`;
chomp $bkup_file;
my $youngest = `svnlook youngest $svn_repo`;
chomp $youngest;
my $dump_command = "svnadmin -q dump $svn_repo > $bkup_dir/$bkup_file ";
print "\nDumping Subversion repo $svn_repo to $bkup_file...\n";
print `$dump_command`;
print "Backing up through revision $youngest... \n";
print "\nCompressing dump file...\n";
print `gzip -9 $bkup_dir/$bkup_file\n`;
chomp $bkup_file;
my $zipped_file = $bkup_dir . "/" . $bkup_file . ".gz";
print "\nCreated $zipped_file\n";
print `scp $zipped_file $bkup_svr_login\@$bkup_svr:/home/backup/`;
print "\n$bkup_file.gz transfered to $bkup_svr\n";
#Test Backup
print "\n---------------------------------------\n";
print "Testing Backup";
print "\n---------------------------------------\n";
print "Downloading $bkup_file.gz from $bkup_svr\n";
print `scp $bkup_svr_login\@$bkup_svr:/home/backup/$bkup_file.gz $tmp_dir/`;
print "Unzipping $bkup_file.gz\n";
print `gunzip $tmp_dir/$bkup_file.gz`;
print "Creating test repository\n";
print `svnadmin create $tmp_dir/test_repo`;
print "Loading repository\n";
print `svnadmin -q load $tmp_dir/test_repo < $tmp_dir/$bkup_file`;
print "Checking out repository\n";
print `svn -q co file://$tmp_dir/test_repo $tmp_dir/test_checkout`;
print "Cleaning up\n";
print `rm -f $tmp_dir/$bkup_file`;
print `rm -rf $tmp_dir/test_checkout`;
print `rm -rf $tmp_dir/test_repo`;
Script source and more details about the rational for this type of backup.
回答by Tom Mayfield
I use svnsync, which sets up a remote server as a mirror/slave. We had a server go down two weeks ago, and I was able to switch the slave into primary position quite easily (only had to reset the UUID on the slave repository to the original).
我使用svnsync,它将远程服务器设置为镜像/从服务器。两周前我们有一台服务器宕机,我能够很容易地将从服务器切换到主位置(只需要将从属存储库上的 UUID 重置为原始位置)。
Another benefit is that the sync can be run by a middle-man, rather than as a task on either server. I've had a client to two VPNs sync a repository between them.
另一个好处是同步可以由中间人运行,而不是作为任一服务器上的任务。我有一个客户端到两个 VPN,在它们之间同步一个存储库。
回答by Adam
svnadmin hotcopy REPOS_PATH NEW_REPOS_PATH
This subcommand makes a full “hot” backup of your repository, including all hooks, configuration files, and, of course, database files.
此子命令对您的存储库进行完整的“热”备份,包括所有挂钩、配置文件,当然还有数据库文件。
回答by Uwe Keim
回答by RobotCaleb
You can create a repository backup (dump) with
svnadmin dump
.You can then import it in using
svnadmin load
.
您可以创建一个存储库备份(转储)用
svnadmin dump
。然后,您可以使用
svnadmin load
.
Detailed reference in the SVNBook: "Repository data migration using svnadmin"
SVNBook中详细参考: 《使用svnadmin进行仓库数据迁移》
回答by atx
Basically it's safe to copy the repository folder if the svn server is stopped. (source: https://groups.google.com/forum/?fromgroups#!topic/visualsvn/i_55khUBrys%5B1-25%5D)
基本上,如果 svn 服务器停止,复制存储库文件夹是安全的。(来源:https: //groups.google.com/forum/?fromgroups#!topic/visualsvn/i_55khUBrys%5B1-25%5D)
So if you're allowed to stop the server, do it and just copy the repository, either with some script or a backup tool. Cobian Backup fits here nicely as it can stop and start services automatically, and it can do incremental backups so you're only backing up parts of repository that have changed recently (useful if the repository is large and you're backing up to remote location).
因此,如果您被允许停止服务器,请使用脚本或备份工具执行并复制存储库。Cobian Backup 非常适合这里,因为它可以自动停止和启动服务,并且可以进行增量备份,因此您只备份最近更改的部分存储库(如果存储库很大并且您要备份到远程位置,则很有用)。
Example:
例子:
- Install Cobian Backup
Add a backup task:
Set source to repository folder (e.g.
C:\Repositories\
),Add pre-backup event
"STOP_SERVICE"
VisualSVN,Add post-backup event,
"START_SERVICE"
VisualSVN,Set other options as needed. We've set up incremental backups including removal of old ones, backup schedule, destination, compression incl. archive splitting etc.
Profit!
- 安装 Cobian 备份
添加备份任务:
将源设置为存储库文件夹(例如
C:\Repositories\
),添加预备份事件
"STOP_SERVICE"
VisualSVN,添加备份后事件,
"START_SERVICE"
VisualSVN,根据需要设置其他选项。我们已经设置了增量备份,包括删除旧备份、备份计划、目的地、压缩包括。档案分割等
利润!
回答by Jose Manuel Ojeda
there are 2 main methods to backup a svn server, first is hotcopy that will create a copy of your repository files, the main problem with this approach is that it saves data about the underlying file system, so you may have some difficulties trying to repostore this kind of backup in another svn server kind or another machine. there is another type of backup called dump, this backup wont save any information of the underlying file system and its potable to any kind of SVN server based in tigiris.org subversion.
备份 svn 服务器有两种主要方法,第一种是 hotcopy,它将创建存储库文件的副本,这种方法的主要问题是它保存了有关底层文件系统的数据,因此您在尝试重新存储时可能会遇到一些困难这种备份在另一个 svn 服务器类型或另一台机器上。还有另一种类型的备份称为转储,这种备份不会保存底层文件系统的任何信息,并且它可以传输到基于 tigiris.org subversion 的任何类型的 SVN 服务器。
about the backup tool you can use the svnadmin tool(it is able to do hotcopy and dump) from the command prompt, this console resides in the same directory where your svn server lives or you can google for svn backup tools.
关于备份工具,您可以从命令提示符使用 svnadmin 工具(它能够进行热复制和转储),该控制台位于您的 svn 服务器所在的同一目录中,或者您可以在 google 上搜索 svn 备份工具。
my recommendation is that you do both kinds of backups and get them out of the office to your email acount, amazon s3 service, ftp, or azure services, that way you will have a securityy backup without having to host the svn server somewhere out of your office.
我的建议是你做这两种备份,让他们离开办公室到你的电子邮件帐户、亚马逊 s3 服务、ftp 或 azure 服务,这样你就可以有一个安全的备份,而不必在外面的某个地方托管 svn 服务器你的办公室。