How to backup and restore all the source code in svn?

和自甴很熟 提交于 2019-11-29 07:45:33

You can just copy the entire directory in and out. Files is files, there's nothing magic about them.

If you want to do something more complicated, like edit the repository contents in some way before restoring, then you need dump and load.

svnadmin dump /path/to/repository | bzip2 -9c > svn-backup.bz2

The compression step is optional, of course.

The primary advantage of this over the "copy the tree" method recommended in another answer is that the Subversion "dump" format is a better archival format than most of the database formats used by Subversion under the hood in its repository. (It's a speed vs. simplicity tradeoff.) You can read a dump file in a text editor, parse it easily, and — most important — import it into a different Subversion repository using a different database back-end.

Restore the above file with:

bzip2 -dc svn-backup.bz2 | svnadmin load /path/to/repository

This is what I use:

#!/bin/bash

mkdir /tmp/backup_svn

for dir in /var/www/svn/*/
    do
        dir=${dir%*/}
        svnadmin dump "${dir}" > "/tmp/backup_svn/${dir##*/}.dmp"
    echo "--- Dump ${dir##*/} done!"
done

To restore the dump you need to create de repo folder before:

svnadmin create /var/www/svn/test

And them:

svnadmin load /var/www/svn/test/ < /tmp/backup_svn/test.dmp

This method will restore all revisions/tags/branches in your repository.

wierob

You should use svnadmin hotcopy to create a backup of your repository.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!