Re: Patch to support dar_manager catalogues

Tristan Rhodes <[email protected]> Sun, 16 Jan 2005 09:04:38 -0700
Newsgroups gmane.comp.sysutils.backup.sarab
Message-ID <[email protected]>
Steven,

Nice job on the patch!  I have never used the dar_manager catalogues so I am glad you added this 
feature.  I plan on adding it to the next version of SaraB.

I have not tested the patch yet, but it looks good.  Thanks for your time and talent.

To everyone else, I apologize for not releasing in a while.  I have a new job that takes most of my 
free time, so SaraB has been left in the low-priority To-Do list.

During my last coding session, I was trying to implement Parchive, which would add redundancy to any 
archive.  This may help recover from physical corruption (such as a scratched DVD).  I also wanted 
to improve my install process, to a more standardized one.  (RPM)

For now, I think I will work on the small bugs that have been pointed out, and include Steven's 
patch.  Hope to get this release in the next month.

Tristan


Steven Clark wrote:
> Hello everyone,
> 
> I started playing around with sarab tonight and I liked what I saw. I
> have implemented a feature so that sarab can manage catalogue files
> using dar_manager. 
> 
> I am attaching the patches in case anyone is interested in playing
> around with this, they are against released version sarab-0.2.2. It
> hasn't been tested extensively yet but it seems to work for me... 
> 
> -Steve 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --- sarab.conf.old	2005-01-16 06:24:33.592004248 -0500
> +++ sarab.conf	2005-01-16 06:26:27.845635056 -0500
> @@ -14,6 +14,9 @@
>  # Default="rotation.schedule"
>  ROTATION_SCHEDULE="rotation.schedule"
>  
> +# Name of the catalogue file to use with dar_manager 
> +CATALOGUE="catalogue"
> +
>  # Root directory where backups will be created and stored 
>  # Note: Use the rotation.schedule file to specify the names of virtual tapes
>  # Default="/mnt/backup/"
> @@ -32,6 +35,9 @@
>  # The email address that will receive notices (see above)
>  EMAIL_ADDRESS="root@$HOSTNAME"
>  
> +# Update the catalogue upon backup create/removal?
> +USE_DAR_MANAGER="yes"
> +
>  # Should SaraB include the statically-compiled DAR executable file with every archive?
>  # This file can be used to restore the archive on any system.  (Size: ~1 MB)
>  # Choose "yes" or "no"
> @@ -70,6 +76,9 @@
>  # The location of the DAR executable file
>  DAR_BINARY="/usr/bin/dar"
>  
> +# The location of the DAR MANAGER executable file
> +DAR_MANAGER="/usr/bin/dar_manager"
> +
>  # The location of the statically-compiled DAR executable file
>  DAR_STATIC="/usr/bin/dar_static"
>  
> 
> 
> ------------------------------------------------------------------------
> 
> --- sarab.sh.old	2005-01-15 18:52:13.000000000 -0500
> +++ sarab.sh	2005-01-16 06:21:57.226775376 -0500
> @@ -232,7 +232,21 @@
>     fi
>  fi
>  
> -verbose
> +# Test to make sure the catalogue file exists if they want us to use it
> +if [ $USE_DAR_MANAGER = "yes" ] && [ ! -f "$SARAB_ETC/$CATALOGUE" ]; then
> +   echo 
> +   echo -n "Creating new catalogue..."
> +   verbose
> +   verbose "Catalogue file does not exist, creating it..."
> +   verbose "$DAR_MANAGER --create $SARAB_ETC/$CATALOGUE"
> +   $DAR_MANAGER --create "$SARAB_ETC/$CATALOGUE"
> +   if [ "$?" != "0" ]; then
> +      echo "ERROR: Failed to create catalogue file. The attempted command was..."
> +      echo "$DAR_MANAGER --create $SARAB_ETC/$CATALOGUE"
> +      exit 1
> +   fi
> +fi
> +
>  # Remove the old backup with the same name, if it exists
>  if [ -d "$DESTINATION/$CURRENT_ARCHIVE/" ]; then
>     verbose "Removing old backup files..."
> @@ -250,9 +264,33 @@
>        echo "rmdir -f $DESTINATION/$CURRENT_ARCHIVE/ "
>        exit 1
>     fi
> +
> +   if [ $USE_DAR_MANAGER = "yes" ]; then
> +      # We need to go through the catalog and delete by path 
> +      # Since dar_manager reorders its archive numbers after every deletion we have to
> +      # reexecute after every deletion to get the updated numbers...
> +      verbose "Searching for existing backups in catalogue to delete..."
> +      while [ 1 ]; do
> +          i=$( $DAR_MANAGER -B $SARAB_ETC/$CATALOGUE -l | grep "\W$DESTINATION/$CURRENT_ARCHIVE\W" | cut -f 2)
> +          if [ -n "$i" ]; then 
> +             i=$( echo $i | cut -f 1 -d" ")
> +             verbose "Deleting record number $i from catalogue..."
> +             verbose "$DAR_MANAGER -B $SARAB_ETC/$CATALOGUE --delete $i"
> +             $DAR_MANAGER -B $SARAB_ETC/$CATALOGUE --delete $i
> +             if [ "$?" != "0" ]; then
> +                echo "ERROR: Failed to delete catalogue record number $i. The attempted command was..."
> +                echo "$DAR_MANAGER -B $SARAB_ETC/$CATALOGUE --delete $i"
> +                exit 1
> +             fi
> +          else 
> +             break
> +          fi
> +      done
> +   fi
>  fi   
>  
>  # Create an empty directory to move the archive into
> +verbose
>  verbose "Creating virtual-tape directory... mkdir $DESTINATION/$CURRENT_ARCHIVE/"
>  mkdir $DESTINATION/$CURRENT_ARCHIVE/
>  
> @@ -266,6 +304,21 @@
>     exit 1
>  fi
>  
> +# Update catalogue with new file
> +if [ $USE_DAR_MANAGER = "yes" ]; then
> +   # Add to the catalog the new backup
> +   echo
> +   echo -n "Adding backup to catalogue"
> +   verbose
> +   verbose "$DAR_MANAGER -B $SARAB_ETC/$CATALOGUE --add $DESTINATION/$CURRENT_ARCHIVE/$BASENAME"
> +   $DAR_MANAGER -B $SARAB_ETC/$CATALOGUE --add $DESTINATION/$CURRENT_ARCHIVE/$BASENAME
> +   if [ "$?" != "0" ]; then
> +      echo "ERROR: Error when adding file to catalogue. The attempted command was..."
> +      echo "$DAR_MANAGER -B $SARAB_ETC/$CATALOGUE --add $DESTINATION/$CURRENT_ARCHIVE/$BASENAME"
> +      exit 1
> +   fi
> +fi
> +
>  # Copy the statically-compiled DAR executable with the arhive
>  if [ "$COPY_DAR" = "yes" ]; then
>     if [ -f "$DAR_STATIC" ]; then

-- 
This message has been scanned for viruses and dangerous
content by MailScanner, and is believed to be clean.



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt