Find the answer to your Linux question:
Results 1 to 2 of 2
Hey guys, I've been working on a single script that will do the following: 1. A bash script checks out specific SVN repositories into a directory on Server 2. Doxygen ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! Prioria's Avatar
    Join Date
    Sep 2010
    Location
    Gainesville, FL
    Posts
    31

    Bash script to integrate SVN, Trac & Doxygen for a backup


    Hey guys, I've been working on a single script that will do the following:

    1. A bash script checks out specific SVN repositories into a directory on Server
    2. Doxygen scans the directory for source code doco generation
    3. Doxygen outputs a directory of .html files generated by the SVN scans
    4. "SVN add" commands add the recently generated directory of Doxygen .html files to the SVN repository
    5. "SVN commit" commands sync the directory with SVN
    6. "Trac-admin" commands regenerate the newly changed Doxygen documentation in Trac-Hack plugin
    7. Dated directories are created for backups
    6. SVNADMIN dumps are created of all repositories
    7. Trac-admin hotcopies generate backup dumps of Trac pages & configuration
    8. VMBoxManage commands stop the Wiki VM, execute an HDClone and restart the VM
    9. Generic output & errors are piped into a dated log file
    10. Entire backup directory is renamed "Current" and copied onto another drive for Barracuda to backup


    Here is what I have so far:



    TM="`eval date +%m-%d-%Y`"
    #Sets Date Variable for Directories & Log file.

    sudo touch /mnt/sdc1/backup_logs/current_backup.log
    #Creates Log file.

    sudo mkdir /media/TBU/backups/$TM
    sudo mkdir /media/TBU/backups/$TM/svn
    #Creates Dated Subversion Backup Directory.

    ( sudo svnadmin dump /mnt/sdb1/svn/repos/eng > /media/TBU/backups/$TM/svn/eng.dump ) 2> /mnt/sdc1/$
    ( sudo svnadmin dump /mnt/sdb1/svn/repos/jms > /media/TBU/backups/$TM/svn/jms.dump ) 2> /mnt/sdc1/$
    ( sudo svnadmin dump /mnt/sdb1/svn/repos/corp > /media/TBU/backups/$TM/svn/corp.dump ) 2> /mnt/sdc$
    ( sudo svnadmin dump /mnt/sdb1/svn/repos/esp > /media/TBU/backups/$TM/svn/esp.dump ) 2> /mnt/sdc1/$
    ( sudo svnadmin dump /mnt/sdb1/svn/repos/it > /media/TBU/backups/$TM/svn/it.dump ) 2> /mnt/sdc1/ba$
    ( sudo svnadmin dump /mnt/sdb1/svn/repos/lcddisp > /media/TBU/backups/$TM/svn/lcddisp.dump ) 2> /m$
    ( sudo svnadmin dump /mnt/sdb1/svn/repos/mist > /media/TBU/backups/$TM/svn/mist.dump ) 2> /mnt/sdc$
    ( sudo svnadmin dump /mnt/sdc1/svn/repos/mr > /media/TBU/backups/$TM/svn/mr.dump ) 2> /mnt/sdc1/ba$
    ( sudo svnadmin dump /mnt/sdb1/svn/repos/vdc > /media/TBU/backups/$T/svn/vdc.dump ) 2> /mnt/sdc1/b$
    #Dumps Repositories into dated directory and pipes standard output & errors into Log file.

    sudo mkdir /media/TBU/backups/$TM/wiki
    sudo killall VirtualBox
    echo -Deki Wiki Stopped >> /mnt/sdc1/backup_logs/current_backup.log
    ( sudo VBoxManage clonehd /mnt/sdb1/vm/MindTouch_Deki_Wiki_itasca_1.9.0a_vm.vmdk /media/TBU/backup$
    #Shuts down the VirtualBox Wiki machine and clones the Virtual drive, piping all output into Log file

    sudo mkdir /media/TBU/backups/$TM/trac

    ( sudo trac-admin /mnt/sdb1/trac/eng hotcopy /media/TBU/backups/$TM/trac/eng.dump ) 2> /mnt/sdc1/b$
    ( sudo trac-admin /mnt/sdb1/trac/jms hotcopy /media/TBU/backups/$TM/trac/jms.dump ) 2> /mnt/sdc1/b$
    #Dumps Trac Environments into dated directory and pipes standard output and errors into Log file.

    ( sudo VBoxManage startvm "Deki Wiki" ) 2> /mnt/sdc1/backup_logs/current_backup.log
    #Restarts the VirtualBox Wiki Machine.

    sudo cp /mnt/sdc1/backup_logs/current_backup.log /media/TBU/backups/$TM/backup.log
    sudo mv /mnt/sdc1/backup_logs/current_backup.log /mnt/sdc1/backup_logs/backup-$TM.log
    #Signals completion of backup & moves the Log file into Dated-Log directory.



    --------------------------------------------------------------------------------------
    sudo rm -rf /mnt/sdc1/backup/current
    sudo cp -rf /media/TBU/backups/$TM /mnt/sdc1/backup/current
    #Copies the Backup directory to SDC1 to be backed up by Barracuda

    #cd /home/prioria/Documents/scripts
    #sudo bash doxy.sh
    #Runs the Doxygen script which will execute an SVN-Checkout to the local machine and create and load documentation of source code into SVN
    echo ---Backup Complete--- >> /mnt/sdc1/backup_logs/current_backup.log


    For the most part, the backups run fine but I am getting conflicting log files. Some dumps aren't generating the correct output and the VirtualBox machine is not restarting correctly. I have yet to perfect the SVN add & commit script that will create doco of SVN and place the doco back inside of SVN.

    Any ideas, tips, hints, anything would be greatly appreciated!

    -Ryan

  2. #2
    Just Joined! Prioria's Avatar
    Join Date
    Sep 2010
    Location
    Gainesville, FL
    Posts
    31
    This is the completed script addition:

    This has been tested on Ubuntu 10.10 Server.

    Script:

    sudo svn cleanup /mnt/sdc1/doxy/svn/<name>
    sudo svn update /mnt/sdc1/doxy/svn/<name>
    sudo svn del /mnt/sdc1/doxy/svn/<name>/doxygen.tar.gz
    sudo doxygen <doxygen-config-file>
    sudo rm -rf /mnt/sdc1/doxy/html/<name>/latex
    sudo rm -rf /mnt/sdc1/doxy/html/<name>/html/*.gz
    sudo tar -zcf /mnt/sdc1/doxy/svn/<name>/doxygen.tar.gz /mnt/sdc1/doxy/html/<name>
    sudo svn add /mnt/sdc1/doxy/svn/<name>/doxygen.tar.gz
    sudo svn commit /mnt/sdc1/doxy/svn/<name> -message

    Script Explained:

    sudo svn cleanup /mnt/sdc1/doxy/svn/<name>
    -Cleans up the SVN directory to minimize automated corruption.
    sudo svn update /mnt/sdc1/doxy/<name>
    -Updates the changed files and revisions from Subversion
    sudo doxygen <doxygen-config-file>
    -Runs Doxygen on the newly checked-out repository
    sudo rm -rf /mnt/sdc1/doxy/html/<name>/latex
    -Removes unwanted “Latex” files (Optional)
    sudo rm -rf /mnt/sdc1/doxy/html/<name>/html/*.gz
    -Deletes the previously versioned Doxygen
    sudo tar -zcf /mnt/sdc1/doxy/svn/<name>/doxygen.tar.gz /mnt/sdc1/doxy/html/<name>
    -Compresses the newly generated Doxygen and places tar.gz back into SVN directory
    sudo svn add /mnt/sdc1/doxy/svn/<name>/doxygen.tar.gz
    -SVN adds the Doxygen tar.gz
    sudo svn commit /mnt/sdc1/doxy/svn/<name> -message
    -Commits the SVN directory with the new Doxygen

    This script can be duplicated and modified for multiple Doxygen scans. Personally, my primary backup script calls a number of these Doxy scripts to generate and compress the documentation, then SVN dump commands immediately backup the entire repository.

    Additionally, Apache aliases can be created for viewing the most recent version of the documentation. TracHack’s Doxygen plug-in is also useful for creating quick “hot-links” to Doxygen alongside Subversion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •