Recovering my svn repository

Posted about 1 year ago

I recently killed Mandriva Spring 2008 on my home server in favor of Debian based Ubuntu Server 8.04 64bit. Now of course I have an automated backup system, which is not great but it certainly gets the job done. My system was and to this moment is using the dump tool, in a very archaic manner with cron jobs. Its very simple but not all too efficient, I do a monthly level 0 dump, weekly level 4 dump, and a daily level 8 dump.

Here is the actual script, it just gets run from 3 different cron jobs:

        #-----------------#
        #    Variables    #
        #-----------------#
        Date=`date +%F`
        MonthlyDir="/artemis/backup/linux/server/monthly"
        WeeklyDir="/artemis/backup/linux/server/weekly"
        DailyDir="/artemis/backup/linux/server/daily"
        MonthlyLog="/artemis/backup/linux/server/monthly/${Date}.log"
        WeeklyLog="/artemis/backup/linux/server/weekly/${Date}.log"
        DailyLog="/artemis/backup/linux/server/daily/${Date}.log"
        #---------------#
        #     Checks    #
        #---------------#
if [ "$UID" != '0' ]
then

        printf "`date +'%F %H:%m:%S'`\nServer backup failed with:\tUser $USER is not root!" \
        | mail -s "Backup failure!" sean@localhost

        exit 1
fi

if [ ! -d /artemis/backup/linux/server ]
then
        printf "Server backup failed with:\nDestination drive, artemis not mounted or path invalid!" \
        | mail -s "Backup failure!" sean@localhost

        exit 2
fi

for e in ${MonthlyDir} ${WeeklyDir} ${DailyDir}
do
        if [ ! -d ${e} ]
        then
                printf "Server backup failed with:\nDirectory (${e}) does not exist or is not mounted!\n" \
                | mail -s "Backup failure!" sean@localhost

                exit 2
        fi
done

case $1 in
        #-----------------------------#
        #    Monthly Backup           #
        #-----------------------------#
        --monthly|--full)

        # Do dump on /home
         /sbin/dump 0 -u -A ${MonthlyDir}/home_${Date}.archive \
        -f ${MonthlyDir}/home_${Date}.dump -j9 /home 2>&1 >> $MonthlyLog
        # Do a dump on /
         /sbin/dump 0 -u -A ${MonthlyDir}/root_${Date}.archive \
        -f ${MonthlyDir}/root_${Date}.dump -j9 / 2>&1 >> $MonthlyLog
        ;;

        #-----------------------------#
        #     Weekly Backup           #
        #-----------------------------#
        --weekly)

        # Do dump on /home
         /sbin/dump 4 -u -A ${WeeklyDir}/home_${Date}.archive \
        -f ${WeeklyDir}/home_${Date}.dump -j9 /home 2>&1 >> $WeeklyLog

        # Do a dump on /
         /sbin/dump 4 -u -A ${WeeklyDir}/root_${Date}.archive \
        -f ${WeeklyDir}/root_${Date}.dump -j9 / 2>&1 >> $WeeklyLog
        ;;

        #-----------------------------#
        #      Daily Backup           #
        #-----------------------------#
        --daily)

        # Do dump on /home
         /sbin/dump 8 -u -A ${DailyDir}/home_${Date}.archive \
        -f ${DailyDir}/home_${Date}.dump -j9 /home 2>&1 >> $DailyLog

        # Do a dump on /
         /sbin/dump 8 -u -A ${DailyDir}/root_${Date}.archive \
        -f ${DailyDir}/root_${Date}.dump -j9 / 2>&1 >> $DailyLog
        ;;

        #-----------------------------#
        #      Help Menu              #
        #-----------------------------#
        --help)
        echo -e "\nThis script is used to backup Brutus using the dump command.\n"
        echo -e "It is truly intended to be used in conjunction with Cron.\n"
        echo -e "Valid options are as follows:\n
        Option:                   Meaning:
        ------------------------|-------------------------------------------
        --help                  | Show this menu.
        --monthly|--full        | Make a full backup.
        --weekly                | Make an incremental weekly backup.
        --daily                 | Make an incremental daily backup."
        ;;

        #-----------------------------#
        #      Anything Else          #
        #-----------------------------#
        *)
        printf "Server backup failed with:\tInvalid or missing option!" | mail -s "Backup failure!" sean@localhost
        echo "server_backup: Invalid or missing option: please see --help"
        ;;
esac

I have read a little about The Tower of Hanoi but never thoroughly enough to completely understand it, let alone use it. This also seems to be geared more toward admins who are using tape to backup their systems where I simply use a hard drive.

Anyway, since I installed a completely new distribution I used nothing but a few server configs from my backups. So I didn’t really have to do any overly complex restoration. Matter of fact I pretty much just dumped the most recent monthly backup and pulled what I needed out and that sufficed fairly well. Until I came to subversion! Duh, duh, duh!!! Obviously that did not work very well and I have been holding off on figuring it out, and because my svn repo was very bare, I nearly just started a new one instead. However, I am always up for a challenge and could not help myself with this one.

It was actually really easy, but restoring from 20 different backups really wasn’t much fun! Anyway I started with my oldest monthly backup, and went to the last. Then began with the weekly backup dated just after the last monthly, and again went through to the newest. Then finally restored the remaining daily backups in the same manner.

My restore command looked like this:

sudo restore -x /svn -f /artemis/backup/linux/server/daily/root_2008-11-13.dump -T /

Yeah, I was restoring di rectly to the svn directory in root rather than /tmp, so what!? I probably could have taken extra time and scripted this, or perhaps just have a better backup rotation. However I think after actually having to use my backups, I will be changing more than just that. I think I am going to go to rsnapshot instead of dump. It just seems much cleaner and simpler to use. I will blog about it once I have it configured.

Well I’m off to bed at 3:00AM once again! I need to get a good workout in tomorrow so I’m going to get some rest, and hammer out chins and pull-ups tomorrow until I drop.

Good night,

Sean

Posted in , ,  | no comments

Comments

(leave url/email »)

   Comment Markup Help Preview comment