]> code.citadel.org Git - citadel.git/blobdiff - citadel/database_cleanup.sh
* database_cleanup.sh: look for /usr/local/ctdlsupport/bin/db_dump and
[citadel.git] / citadel / database_cleanup.sh
index 41a7f5cad85b5c21d233719a3c5fdea3ce7f879b..4cd0638e760907ec3042bbdee175de2bf464209e 100755 (executable)
@@ -1,5 +1,19 @@
 #!/bin/bash
 
+die () {
+       echo Exiting.
+       exit 1
+}
+
+
+# If we're on an Easy Install system, use our own db_ tools.
+#
+if [ -x /usr/local/ctdlsupport/bin/db_dump ] ; then
+       export PATH=/usr/local/ctdlsupport/bin:$PATH
+fi
+
+# Ok, let's begin.
+#
 clear
 cat <<!
 
@@ -12,8 +26,16 @@ any data corruption issues, this program may be able to clean them up for you.
 Please note that this program does a Berkeley DB dump/load, not a Citadel
 export.  The export files are not generated by the Citadel export module.
 
-MAKE A BACKUP OF YOUR DATA BEFORE ATTEMPTING THIS.  There is no guarantee
-that this will work!
+WARNING #1:
+  MAKE A BACKUP OF YOUR DATA BEFORE ATTEMPTING THIS.  There is no guarantee
+  that this will work!
+
+WARNING #2:
+  citserver must NOT be running while you do this.
+
+WARNING #3:
+  Please try "db_recover -c" from the data/ directory first.  Use this tool
+  only if that one fails to fix your problem.
 
 !
 
@@ -34,7 +56,7 @@ for x in 00 01 02 03 04 05 06 07 08
 do
        filename=cdb.$x
        echo Dumping $filename
-       db_dump -h ./data $filename >/tmp/CitaDump.$x
+       db_dump -h ./data $filename >/tmp/CitaDump.$x || die
        rm -f ./data/$filename
 done
 
@@ -45,8 +67,9 @@ for x in 00 01 02 03 04 05 06 07 08
 do
        filename=cdb.$x
        echo Loading $filename
-       db_load -h ./data $filename </tmp/CitaDump.$x
-       rm -f /tmp/CitaDump.$x
+       db_load -h ./data $filename </tmp/CitaDump.$x && {
+               rm -f /tmp/CitaDump.$x
+       }
 done
 
 echo