GIT – This is quick guide, howto Backup (dump) and Restore (load) (Subversion) repository on Linux. This is actually very simple and important task. SVN backup and restore is useful when you want to move your repos to new or you need to recover your data.

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  then remember also set  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 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
Print Friendly

Comments

comments

Bài viết liên quan