2013年12月6日 星期五
SVN (Subversion) Backup and Restore
1. Backup (dump) SVN (Subversion) repository
1.1 Create Dump from SVN (Subversion) repository
svnadmin dump /path/to/reponame > /path/to/reponame.dump
Real example
svnadmin dump /var/www/svn/testrepo > /backups/testrepo.dump
1.2 Gzip Created Dump
gzip -9 /path/to/reponame.dump
Real example
gzip -9 /backups/testrepo.dump
1.3 SVN Dump and Gzip Dump with One-liner
svnadmin dump /path/to/reponame | gzip -9 > /path/to/reponame.dump.gz
Real example
svnadmin dump /var/www/svn/testrepo | gzip -9 > /backups/testrepo.dump.gz
2. Restore (load) SVN (Subversion) repository
2.1 Unzip Dump File
gunzip /path/to/reponame.dump.gz
Real example
gunzip /backups/testrepo.dump.gz
2.2 Create Empty SVN (Subversion) Repository
svnadmin create /path/to/reponame
Real example
svnadmin create /var/www/svn/testrepo
2.3 Setup SVN (Subversion) Repository Permissions
chown -R svnuser:svngroup /path/to/reponame
## If you use SELinux then remember also set security context ##
chcon -R -t httpd_sys_content_t /path/to/reponame
## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /path/to/reponame
Real example
chown -R apache:apache /var/www/svn/testrepo
## Set security context ##
chcon -R -t httpd_sys_content_t /var/www/svn/testrepo
## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo
2.4 Load Data to Repository from SVN (Subversion) Backup
svnadmin load /path/to/reponame < /path/to/reponame.dump
Real example
svnadmin load /var/www/svn/testrepo < /backups/testrepo.dump
3. Automatic SVN (Subversion) Repository Backups
3.1 Edit Crontab
crontab -e
3.2 Add SVN Dump Command to Crontab
@daily svnadmin dump /path/to/reponame > /path/to/reponame.dump
## OR ##
@weekly svnadmin dump /path/to/reponame > /path/to/reponame.dump
Real example
@weekly svnadmin dump /var/www/svn/testrepo > /backups/testrepo.dump
3.3 More Advanced SVN Dump Example with Time and Date and Gzip
@daily svnadmin dump /path/to/reponame | gzip -9 > /path/to/reponame-$(date +"\%Y-\%m-\%d-\%T").dump.gz
Real example
@daily svnadmin dump /var/www/svn/testrepo | gzip -9 > /backups/testrepo-$(date +"\%Y-\%m-\%d-\%T").dump.gz
以上文章摘自
http://www.if-not-true-then-false.com/2012/svn-subversion-backup-and-restore/
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言