Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this command that I'm told will do a full backup of Subversion (tell me if that's not true):

svnadmin dump /shared/svnrepos | gzip /shared/backup/snvfull.svn.gz

I'm not a Linux person. I just simply want it to run nightly at 7pm and overwrite the file nightly. It takes quite a while to run though (around 4-5 hours creating around a 28GB file)

Can someone please tell me how to set it up as a cron job in Linux as the root user? (It's Gentoo if that matters)

If it's easier to run a Windows task from the "backup server" just let me know how to create that task to remote in via SSH and run that command as the root user.

Thank you!

P.S. if there's a better/easier way to backup a large SVN, please let me know...I know nothing about Subversion but I'm still stuck dealing with it.

share|improve this question
up vote 2 down vote accepted

Your command will work.

Create a dump script such as

date=`date +%Y-%m-%d`
svnadmin dump /shared/svnrepos | gzip /shared/backup/snvfull_$date.svn.gz

Edit Crontab file crontab -e add

0 19 * * * root /path-to-svn-dump/ file 

every day at 7pm this will dump your file

On windows create a bat file such as

for /F "tokens=6,7,8 delims=/ " %%i in ('echo.^|date^|find "current" ') do set today=%%k%%j%%i

set backupdate=%today%
cd "C:\backups\svn"

svnadmin dump "C:\svn_repository\your_repo" > "C:\backups\svn\yourbackup_%backupdate%.svn"

Add this file to scheduled jobs for desired time to run.

share|improve this answer
This works but I just need it to overwrite the .gz file need for multiple dates that I can tell. – TheCleaner Aug 14 '12 at 19:26
then remove date use same file name that should work for you. – PoX Aug 14 '12 at 19:43
BTW, I should note that I had to set the permissions to 755 to get it to run. You probably knew that, but I didn't. – TheCleaner Aug 22 '12 at 13:24
I should also add, I was having trouble with it finishing. Apparently after some searching it is a known bug. You have to redirect output such as > /var/log/svndump.log 2>&1 – TheCleaner Aug 30 '12 at 20:05

svnadmin dump should work but you can also use svnandmin hotcopy. I use the following script from cron to back up multiple repositories, compress them and keep the last few days:

# Backup-svn: Back up each repository under /svn using 'svnadmin hotcopy'.

date_stamp=`date +%Y-%m-%d`
repo_list=`ls -d $svn_dir/*/conf | sed -e "s:^$svn_dir/::" -e 's:/conf$::'`

renice 5 -p $$ > /dev/null 2>&1
ionice -c 3 -p $$ > /dev/null 2>&1

cd $backup_dir

for repo in $repo_list ; do

    rm -rf $dest_tmp

    date +"%F %T: Starting hotcopy for $repo"
    svnadmin hotcopy $svn_dir/$repo $dest_tmp

    date +"%F %T: Archiving $repo"
    tar -czf $dest.tar.gz $dest_tmp
    du -sh $dest.tar.gz $dest_tmp

    date +"%F %T: Removing $repo"
    rm -rf $dest_tmp &

    for old_backup in `ls $repo-2*.tar.gz | sort -r | sed "1,${keep_days}d"` ; do
        date +"%F %T: Removing $old_backup"
        rm $old_backup
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.