Difference between revisions of "Subversion backup and restore"

From ArchWiki
Jump to: navigation, search
m (Style clean up.)
(19 intermediate revisions by 9 users not shown)
Line 1: Line 1:
[[Category:Installation]]
+
[[Category:Version Control System]]
[[Category:System Configuration]]
+
{{Poor writing}}
  
* Howto backup Subversion and move it to a new machine.
+
This article deals with how to backup your Subversion data and move it to a new machine. For a detailed article on setting up Subversion, see [[Subversion Setup]].
* <b>Back Up Your Data !</b>
+
  
* svnadmin dump repo and scp to other machine.
+
== Instruction ==
* Do this for each repository you have.
+
svnadmin dump repo and scp to other machine
<pre>
+
Do this for each repository you have.
svnadmin dump /path/to/reponame > /tmp/reponame.dump ; scp -rp /tmp/reponame.dump user@server.domain.com:/tmp/
+
svnadmin dump /path/to/reponame > /tmp/reponame.dump ; scp -rp /tmp/reponame.dump user@server.domain.com:/tmp/
</pre>
+
  
* On other machine install subversion
+
On other machine install subversion
<pre>
+
pacman -S subversion
pacman -Sy subversion
+
</pre>
+
  
* Create the corrisponding repositories.
+
Make sure you set svnserve in /etc/rc.conf
* Do this for each repository you have.
+
Edit the DAEMONS line so it starts on next boot.
<pre>
+
DAEMONS=(syslog-ng hotplug !pcmcia network netfs crond sshd svnserve httpd)
svnadmin create /path/to/reponame
+
</pre>
+
  
* Load svn dump into new repo on new machine.
+
Create the corresponding repositories. Do this for each repository you have.
* Do this for each repository you have.
+
svnadmin create /path/to/reponame
<pre>
+
svnadmin load /path/to/reponame < /tmp/repo1.dump
+
</pre>
+
  
* Setting Permissions.. <b>CRUCIAL</b>
+
Load svn dump into new repo on new machine. Do this for each repository you have.
* This is the most common mistake when moving a svn repo.
+
svnadmin load /path/to/reponame < /tmp/repo1.dump
* Do this for each repository you have.
+
<pre>
+
chown -R svn:svnusers /path/to/reponame ; chmod -R g+w /path/to/reponame/db/
+
</pre>
+
  
* Sample Permissions:
+
Setting Permissions.. <b>CRUCIAL</b> This is the most common mistake when moving an svn repo.
<pre>
+
Do this for each repository you have.
bash-2.05b# ls -l | grep svn
+
chown -R svn:svnusers /path/to/reponame ; chmod -R g+w /path/to/reponame/db/
 +
 
 +
Sample Permissions:
 +
{{bc|bash-2.05b# ls -l | grep svn
 
drwxrwxr-x  7 svn  svnusers      512 Apr 27 15:06 reponame1
 
drwxrwxr-x  7 svn  svnusers      512 Apr 27 15:06 reponame1
 
drwxrwxr-x  7 svn  svnusers      512 Apr 27 15:06 reponame2
 
drwxrwxr-x  7 svn  svnusers      512 Apr 27 15:06 reponame2
Line 43: Line 33:
 
bash-2.05b# ls -l reponame1/ | egrep -i "db"
 
bash-2.05b# ls -l reponame1/ | egrep -i "db"
 
drwxrwsr-x  2 svn  svnusers  512 Apr 27 15:07 db
 
drwxrwsr-x  2 svn  svnusers  512 Apr 27 15:07 db
bash-2.05b#
+
}}
</pre>
+
 
   
 
   
* Ok these repos should be allset and ready to rock.. however using svn+ssh:// will not work..  
+
Ok these repos should be all set and ready to rock.. however using svn+ssh:// will not work..  
* <b>Note</b>: we have to have a wrapper written for svnserve..  
+
{{Note|we have to have a wrapper written for svnserve.. PLEASE FOLLOW CLOSELY HERE}}
  
* <b>PLEASE FOLLOW CLOSELY HERE</b>
+
check your ENV like:
 
+
{{bc| bash-2.05b# env | egrep "^PATH="
* check your ENV like:
+
<pre>
+
bash-2.05b# env | egrep "^PATH="
+
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
bash-2.05b#
+
}}
</pre>
+
  
* check where the svnserve binary is located:
+
check where the svnserve binary is located:
<pre>
+
{{bc| # which svnserve
bash-2.05b# which svnserve
+
 
/usr/local/bin/svnserve
 
/usr/local/bin/svnserve
bash-2.05b#
+
}}
</pre>
+
  
* ok our wrapper is going to have to fall in PATH prior to this location.. /sbin is a good place seeing its our 1st exec path on the system as root.
+
ok our wrapper is going to have to fall in PATH prior to this location.. /sbin is a good place seeing its our 1st exec path on the system as root.
  
* create wrapper:
+
create wrapper:
<pre>
+
touch /sbin/svnserve ; chmod 755 /sbin/svnserve  
touch /sbin/svnserve ; chmod 755 /sbin/svnserve  
+
</pre>
+
  
* now edit it to look like so:
+
now edit it to look like so:
  
<pre>
+
{{bc| bash-2.05b# cat /sbin/svnserve  
bash-2.05b# cat /sbin/svnserve  
+
 
#!/bin/sh
 
#!/bin/sh
 
# wrapper script for svnserve
 
# wrapper script for svnserve
 
umask 007
 
umask 007
 
/usr/local/bin/svnserve -r /path/to "$@"
 
/usr/local/bin/svnserve -r /path/to "$@"
bash-2.05b#
+
}}
</pre>
+
  
* NOTE: see the -r /path/to ?? well this is what makes use of the svn co svn+ssh://server.domain.com:/reponame ( SEE THIS :/reponame ).. this sets root PATH.
+
{{Note|See the -r /path/to ?? well this is what makes use of the svn co svn+ssh://server.domain.com:/reponame ( SEE THIS :/reponame ).. this sets root PATH.}}
* you do not need to do: :/path/to/reponame.... this is the big trick here folks.
+
You do not need to do: :/path/to/reponame.... this is the big trick here folks.
  
* Start svnserve with new wrapper script like so:
+
Start svnserve with new wrapper script like so:
<pre>
+
/sbin/svnserve -d  ( start daemon mode )
/sbin/svnserve -d  ( start daemon mode )
+
</pre>
+
  
* check it with ps:
+
check it with ps:
 
+
{{bc| # ps auxww | grep svn
<pre>
+
bash-2.05b# ps auxww | grep svn
+
 
root  66668  0.0  0.1  3608 1868  ??  Is  12:25AM  0:00.00 /usr/local/bin/svnserve -r /path/to -d
 
root  66668  0.0  0.1  3608 1868  ??  Is  12:25AM  0:00.00 /usr/local/bin/svnserve -r /path/to -d
bash-2.05b#
+
}}
</pre>
+
  
* we can also check the perms for remote users like this:
+
we can also check the perms for remote users like this:
  
<pre>
+
{{bc|cdowns:~ ~$ svn ls svn+ssh://server.domain.com:/reponame
cdowns:~ ~$ svn ls svn+ssh://server.domain.com:/reponame
+
 
++server.domain.com++
 
++server.domain.com++
 
dev/
 
dev/
Line 108: Line 81:
 
release/
 
release/
 
cdowns:~ ~$
 
cdowns:~ ~$
</pre>
+
}}
 
+
* Thats it !
+
<pre>
+
Thats it !
+
 
+
Extra Docs:
+
http://svnbook.red-bean.com/en/1.1/svn-book.html#svn-ch-9-sect-2.2-re-load
+
http://subversion.tigris.org/
+
</pre>
+
  
* cdowns\@drippingdead.com
+
== See Also ==
 +
* http://svnbook.red-bean.com/en/1.1/svn-book.html#svn-ch-9-sect-2.2-re-load
 +
* http://subversion.tigris.org/

Revision as of 11:23, 19 June 2012

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Subversion backup and restore#)

This article deals with how to backup your Subversion data and move it to a new machine. For a detailed article on setting up Subversion, see Subversion Setup.

Instruction

svnadmin dump repo and scp to other machine Do this for each repository you have.

svnadmin dump /path/to/reponame > /tmp/reponame.dump ; scp -rp /tmp/reponame.dump user@server.domain.com:/tmp/

On other machine install subversion

pacman -S subversion

Make sure you set svnserve in /etc/rc.conf Edit the DAEMONS line so it starts on next boot.

DAEMONS=(syslog-ng hotplug !pcmcia network netfs crond sshd svnserve httpd)

Create the corresponding repositories. Do this for each repository you have.

svnadmin create /path/to/reponame

Load svn dump into new repo on new machine. Do this for each repository you have.

svnadmin load /path/to/reponame < /tmp/repo1.dump

Setting Permissions.. CRUCIAL This is the most common mistake when moving an svn repo. Do this for each repository you have.

chown -R svn:svnusers /path/to/reponame ; chmod -R g+w /path/to/reponame/db/

Sample Permissions:

bash-2.05b# ls -l 

Ok these repos should be all set and ready to rock.. however using svn+ssh:// will not work..

Note: we have to have a wrapper written for svnserve.. PLEASE FOLLOW CLOSELY HERE

check your ENV like:

 bash-2.05b# env 

check where the svnserve binary is located:

 # which svnserve
/usr/local/bin/svnserve

ok our wrapper is going to have to fall in PATH prior to this location.. /sbin is a good place seeing its our 1st exec path on the system as root.

create wrapper:

touch /sbin/svnserve ; chmod 755 /sbin/svnserve 

now edit it to look like so:

 bash-2.05b# cat /sbin/svnserve 
#!/bin/sh
# wrapper script for svnserve
umask 007
/usr/local/bin/svnserve -r /path/to "$@"
Note: See the -r /path/to ?? well this is what makes use of the svn co svn+ssh://server.domain.com:/reponame ( SEE THIS :/reponame ).. this sets root PATH.

You do not need to do: :/path/to/reponame.... this is the big trick here folks.

Start svnserve with new wrapper script like so:

/sbin/svnserve -d  ( start daemon mode )

check it with ps:

 # ps auxww 

we can also check the perms for remote users like this:

cdowns:~ ~$ svn ls svn+ssh://server.domain.com:/reponame
++server.domain.com++
dev/
qa/
release/
cdowns:~ ~$

See Also