[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Problem using "svnadmin dump" in a cron job

From: Ryan Schmidt <subversion-2008c_at_ryandesign.com>
Date: Sun, 20 Jul 2008 21:21:18 -0500

On Jul 20, 2008, at 12:28, Robert Dailey wrote:

> I'm currently using crontab to setup a backup script that runs at
> various intervals to backup my subversion repository. First, it
> performs an "svnadmin dump" as user 'root' in Ubuntu Server 8.04.
> Next, it utilizes the '7z' program to compress the dump file. I'm
> having an issue right now where the dump process will just cease to
> continue at any given random location in the dump process. For
> example, it might go all the way up to revision 26 and then stop
> there, instead of performing the dump for all revisions in the
> repository. The revision that the dump stops at seems to be random.
>
> Below is my crontab file for user 'root', which I access by executing:
> su -c "crontab -e"
> ------------------------------------------------------------------
> ENV=/home/robert/.profile
> SHELL=/bin/sh
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
>
> # m h dom mon dow command
> 41 10 * * * script -c "/var/svn/scripts/backup" -f "/tmp/
> svnbackup.log"
> ------------------------------------------------------------------
>
> And this is my "/var/svn/scripts/backup" bash script file:
> ------------------------------------------------------------------
> #!/bin/bash
>
> # Backup the 'personal' repository.
> filename=$(date +%Y-%m-%d)
>
> # Create destination directory first
> dst_dir="/var/svn/backup"
> if [ ! -e $dst_dir ]; then
> mkdir -p $dst_dir
> echo "Created ${dst_dir}"
> fi
>
> filepath=${dst_dir}/${filename}
>
> # Create the dump file
> echo "Starting dump process..."
> svnadmin dump /var/svn/repo/personal > ${filepath}.tmp_dump

You should log the stderr output too, not just the stdout output.
This way when an error occurs you should know why.

svnadmin dump /var/svn/repo/personal > ${filepath}.tmp_dump 2>&1

> echo "Dump process finished"
> if [ "$?" != "0" ]; then
> echo "Failed to generate dump file"

Usually you would print errors to stderr, not stdout.

echo "Failed to generate dump file" 1>&2

> exit 1
> fi
>
> # Attempt to compress the dump file
> echo "Beginning to compress dump file..."
> 7z a -mx=9 -ms=on ${filepath}.7z ${filepath}.tmp_dump
> echo "Dump file now compressed"
> if [ "$?" != "0" ]; then
> echo "Failed to compress the dump file"

Same here.

echo "Failed to compress the dump file" 1>&2

> exit 1
> fi
>
> # Remove old tmp_dump file, but only if the
> # compression was successful.
> #echo "Deleting uncompressed dump file..."
> #rm ${filepath}.tmp_dump
>
> echo "Backup process completed."
> ------------------------------------------------------------------
>
> And finally, below is the contents of the "/tmp/svnbackup.log" file.
> Notice how it stops at revision 26 for no reason at all: No error, no
> warning, nothing...
> ------------------------------------------------------------------
> Script started on Sun Jul 20 12:17:01 2008
> Starting dump process...
> * Dumped revision 0.
> * Dumped revision 1.
> * Dumped revision 2.
> * Dumped revision 3.
> * Dumped revision 4.
> * Dumped revision 5.
> * Dumped revision 6.
> * Dumped revision 7.
> * Dumped revision 8.
> * Dumped revision 9.
> * Dumped revision 10.
> * Dumped revision 11.
> * Dumped revision 12.
> * Dumped revision 13.
> * Dumped revision 14.
> * Dumped revision 15.
> * Dumped revision 16.
> * Dumped revision 17.
> * Dumped revision 18.
> * Dumped revision 19.
> * Dumped revision 20.
> * Dumped revision 21.
> * Dumped revision 22.
> * Dumped revision 23.
> * Dumped revision 24.
> * Dumped revision 25.
> * Dumped revision 26.
> ------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-07-21 04:21:52 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.