Index: trunk/Mars/datacenter/scripts/budb
===================================================================
--- trunk/Mars/datacenter/scripts/budb	(revision 11841)
+++ trunk/Mars/datacenter/scripts/budb	(revision 11842)
@@ -18,13 +18,15 @@
 #
 #
-#   Author(s): Daniela Dorner  10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
+#   Author(s): Daniela Dorner  10/2006 <mailto:daniela.dorner@unige.ch>
 #
-#   Copyright: MAGIC Software Development, 2000-2008
+#   Copyright: MAGIC Software Development, 2000-2011
 #
 #
 # ========================================================================
 #
-# This script backups the Magic Database. 
-# In addition it writes out the commands how to create the database. 
+# This script backups the databases give in setup.XXX in the array dbnames
+# 
+# In addition, it writes out the commands how to create the database 
+# MyMagic, in case all databases are backuped. 
 #
 
@@ -37,17 +39,11 @@
 set -C
 
-path=/home/`whoami`/budb
+path=/home/`whoami`/DB_Backup
 logpath=$path/log
+filepath=$path/files
 mkdir -pv $logpath
+mkdir -pv $filepath
 logfile=$logpath/budb$today.log
 oldlog=$logpath/budb$olday.log
-file=$path/alldatabases
-end=.sql.bz2
-zipfile=$file$today$end
-oldzip=$file$olday$end
-
-dbname=MyMagic
-command=$path/Create$dbname$today.txt
-oldcommand=$path/Create$dbname$olday.txt
 
 date > $logfile
@@ -57,23 +53,89 @@
 echo "date to remove: $olday" >> $logfile 2>&1
 
-echo "removing old files..." >> $logfile 2>&1
-rm -v $oldzip >> $logfile 2>&1
-rm -v $oldlog >> $logfile 2>&1
-rm -v $oldcommand >> $logfile 2>&1
+if ls $oldlog >/dev/null 2>&1
+then 
+   echo "removing old logfile..." >> $logfile 2>&1
+   rm -v $oldlog >> $logfile 2>&1
+fi
 
-echo "writing all databases to $zipfile..." >> $logfile 2>&1
+if [ "${dbnames[0]}" == "all" ]
+then
+   dbname=MyMagic
+   command=$filepath/Create$dbname$today.txt
+   oldcommand=$filepath/Create$dbname$olday.txt
+   file=$filepath/alldatabases
+   end=.sql.bz2
+   zipfile=$file$today$end
+   oldzip=$file$olday$end
 
-# complete databases 
-if ! mysqldump --host=$ho --all-databases -u dump | bzip2 -9 -c >| $zipfile 2>> $logfile
-then
-   printprocesslog "ERROR mysqldump failed "
-   echo "ERROR mysqldump failed " >> $logfile 2>&1
-fi
-echo "writing create commands to $command..." >> $logfile 2>&1
-# commands to create MyMagic
-if ! mysqldump --host=$ho --database $dbname -u dump --no-data >| $command 2>> $logfile
-then
-   printprocesslog "ERROR mysqldump failed "
-   echo "ERROR mysqldump failed " >> $logfile 2>&1
+   echo "removing old files..." >> $logfile 2>&1
+   if ls $oldzip >/dev/null 2>&1
+   then 
+      rm -v $oldzip >> $logfile 2>&1
+   fi
+   if ls $oldcommand >/dev/null 2>&1
+   then 
+      rm -v $oldcommand >> $logfile 2>&1
+   fi
+  
+   echo "writing create commands to $command..." >> $logfile 2>&1
+   # commands to create MyMagic
+   if ! mysqldump --host=$ho --database $dbname -u dump --no-data >| $command 2>> $logfile
+   then
+      printprocesslog "ERROR mysqldump failed "
+      echo "ERROR mysqldump failed " >> $logfile 2>&1
+   fi
+
+   echo "writing all databases to $zipfile..." >> $logfile 2>&1
+   # complete databases 
+   if ! mysqldump --host=$ho --all-databases -u dump | bzip2 -9 -c >| $zipfile 2>> $logfile
+   then
+     printprocesslog "ERROR mysqldump failed "
+     echo "ERROR mysqldump failed " >> $logfile 2>&1
+   fi
+else 
+   echo "doing backup for the following databases: "${dbnames[@]}  >> $logfile 2>&1
+   for dbname in ${dbnames[@]}
+   do 
+      filepath2=$filepath/$dbname
+      command=$filepath2"/Create_"$dbname"_"$today".txt"
+      oldcommand=$filepath2"/Create_"$dbname"_"$olday".txt"
+      mkdir -pv $filepath2
+
+      file=$filepath2/$dbname
+      end=.sql.bz2
+      zipfile=$file"_"$today$end
+      oldzip=$file"_"$olday$end
+
+      echo "removing old files..." >> $logfile 2>&1
+      if ls $oldzip >/dev/null 2>&1
+      then
+         rm -v $oldzip >> $logfile 2>&1
+      fi
+      if ls $oldlog >/dev/null 2>&1
+      then
+         rm -v $oldlog >> $logfile 2>&1
+      fi
+      if ls $oldcommand >/dev/null 2>&1
+      then
+         rm -v $oldcommand >> $logfile 2>&1
+      fi
+
+      echo "writing create commands to $command..." >> $logfile 2>&1
+      # commands to create db
+      if ! mysqldump --host=$ho --database $dbname -u dump --no-data >| $command 2>> $logfile
+      then
+         printprocesslog "ERROR mysqldump failed "
+         echo "ERROR mysqldump failed " >> $logfile 2>&1
+      fi
+
+      echo "writing database $dbname to $zipfile..." >> $logfile 2>&1
+      
+      if ! mysqldump --host=$ho --database $dbname -u dump | bzip2 -9 -c >| $zipfile 2>> $logfile
+      then
+        printprocesslog "ERROR mysqldump failed "
+        echo "ERROR mysqldump failed " >> $logfile 2>&1
+      fi
+   done
 fi
 
Index: trunk/Mars/datacenter/scripts/setup.wue.fact.mc
===================================================================
--- trunk/Mars/datacenter/scripts/setup.wue.fact.mc	(revision 11841)
+++ trunk/Mars/datacenter/scripts/setup.wue.fact.mc	(revision 11842)
@@ -41,4 +41,7 @@
 sitekey=1
 storagesite=wue
+
+# for db backup
+dbnames=( "TestFACTSetup" )
 
 # queuing system
Index: trunk/Mars/datacenter/scripts/setup.wue.magic.data
===================================================================
--- trunk/Mars/datacenter/scripts/setup.wue.magic.data	(revision 11841)
+++ trunk/Mars/datacenter/scripts/setup.wue.magic.data	(revision 11842)
@@ -40,4 +40,7 @@
 queuesys=condor # wuerzburg data center
 condorpath=/usr/local/bin
+
+# for db backup
+dbnames=( "all" )
 
 # logging and setup
