Thursday, August 30, 2012

SVN backup on Unix or Solaris

I made a simple script to backup SVN shell script. It is working on ssh terminal on my session well. but when it run by crontab. it is not running and leave no error message. It was difficult to solve this issue if there is no error message.

My colleague who is expert Unix system gave me an advice, check email on Unix. I have searched how to check email on Unix. time by time I am noticed that there is new email. I didn't know I can read that from the server.

'mailx' this is the command to check email. then you can select number to read email. I found the log from crontab, it seems few library and command it not found. I copy PATH, LD_LIBRARY_PATH, LD_RUN_PATH variables to shell script. you can get the variable definition when you type 'env'

In the end, it's running.

datum=`/bin/date +%Y%m%d`



export PATH
export LD_RUN_PATH

/usr/local/bin/svnadmin dump /home/svn/sfc > /home/backup_nas/svn/sfc_$datum.dump

- SVN Backup
nohup svnadmin dump /home/svn/sfc > /home/backup_all/svn/sfc.dump &

- SVN incremental Backup
$ svnadmin dump myrepos --revision 0:1000 > dumpfile1
$ svnadmin dump myrepos --revision 1001:2000 --incremental > dumpfile2
$ svnadmin dump myrepos --revision 2001:3000 --incremental > dumpfile3
svnadmin dump  -r 58:HEAD --deltify >  

- SVN recovery
svnadmin load < ~/repos-0-1000.svn_dump
svnadmin load < ~/repos-1000-2000.svn_dump
svnadmin load < ~/repos-2000-3000.svn_dump

- SVN revision pack per 1000 revision
svnadmin pack /home/svn/sfc

- SVN repository create
/usr/local/bin/svnadmin create path/to/repos

- SVN daemon shutdown
pkill -KILL svnserve

- SVN daemon start
svnserve -d -r /home/svn/