NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

orangeshasta's avatar
orangeshasta
Aspirant
May 03, 2013

Subversion Repo Backup

I'm running a subversion repository on my ReadyNAS Ultra 4+ using the subversion add-on. I'm relatively new to Subversion, so I'm wondering what techniques others are using to backup their repos. I've heard that the best practice to periodically do a "svnadmin dump" on the repo for backup; however I'm not sure how I can automate my ReadyNAS to do that on its own. Right now I'm just doing a backup on the entire [c] folder, which is not ideal.

Is there a way I can write a script or something to achieve the "dump" functionality?

1 Reply

  • Okay, I've successfully gotten a shell script running that will dump all of my subversion repositories to both a shared folder, and a USB hard drive. I largely made use of the example from this site: http://www.hossainkhan.info/content/shell-script-backup-all-your-svn-repositories

    The meat of the script is below:

    #!/bin/sh

    # Record todays date
    # --------------------
    bakdate=$(date +"%Y-%m-%d %H;%M;%S")
    echo "--------------------------------"
    echo "Running SVN backup $bakdate"
    echo "--------------------------------"

    # From where to backup repos?
    # ---------------------------
    svnrepos="/opt/subversion"
    echo "Going to backup all SVN repos located at: $svnrepos"

    # Where to save the dump?
    # ------------------------
    bakdest="/Engineering/ENGR ADMIN/SVN Dumps"
    bakfolder="$bakdest/$bakdate"

    # Location for USB drive? (to copy backup)
    # ----------------------------------------
    baktousb="/USB_HDD_1/svn"
    baktousbfolder="$baktousb/$bakdate"


    # _________NO-COFIG-REQUIRED-BELOW-THIS-LINE___________

    # First go to SVN repo folder
    cd $svnrepos

    # Just make sure we have write access to backup-folder
    if [ -d "$bakdest" ] && [ -w "$bakdest" ] ; then
    mkdir "$bakfolder"
    # Now $repo has folder names = project names
    for repo in *; do
    # Do svn dump for each project
    echo "Taking backup/svndump for: $repo"
    echo "Executing : svnadmin dump $repo > $bakfolder/$repo-$bakdate.svn.dump"
    # Now finally execute the backup
    svnadmin dump $repo > "$bakfolder/$repo-$bakdate.svn.dump"

    # You can go the extra mile by applying tar-gz copmression to svn-dumps
    #svnadmin dump $repo --deltas | gzip > "$bakfolder/$repo-$bakdate.svn.dump.gz"

    # We also would like to save the dump to remote place/USB
    if [ -d "$baktousb" ] && [ -w "$baktousb" ] ; then
    #USB/other directory exists, copy the dump there
    mkdir -p "$baktousbfolder"
    echo "Going to copy $repo dump to $baktousb directory..."
    cp "$bakfolder/$repo-$bakdate.svn.dump" "$baktousbfolder"
    fi
    done
    else
    echo "Unable to continue SVN backup process."
    echo "$bakdest is *NOT* a directory or you do not have write permission."
    fi

    # End of backup script
    echo "================================="
    echo " SVN Backup Complete!"
    echo "================================="
    echo " - Backup Complete, THANK YOU :-]"


    However, I've run into some problems in trying to automate it. I want to do daily backups, so I named this file svnbackup_cron (with no extension) and placed it in the cron.daily folder. If I log in as root and run the script manually, it executes without any problem. However, when it runs automatically, it only dumps the contents of five of my seven repositories. And, it only copies four of those to the USB drive. I've checked for errors in /var/log/cron.log and didn't see any.

    What might be going on here? I haven't been able to find anything out by googling.

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More