]> code.citadel.org Git - citadel.git/blobdiff - citadel/database_cleanup.sh
* The EUID index is now built, and replication checks are being performed
[citadel.git] / citadel / database_cleanup.sh
index faf8a560a33a88c4fe5b4de25366047cb02beb71..4a37bba767035d74882143d15494fa0e34479dab 100755 (executable)
@@ -1,9 +1,23 @@
 #!/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 <<!
 
-Citadel/UX Database Cleanup
+Citadel Database Cleanup
 ---------------------------
 
 This script exports, deletes, and re-imports your database.  If you have
@@ -12,8 +26,20 @@ 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.
+
+WARNING #4:
+  You must have an amount of free space on your disk that is at least twice
+  the size of your database.
 
 !
 
@@ -30,23 +56,24 @@ case "$yesno" in
                exit
 esac
 
-for x in 00 01 02 03 04 05 06 07 08
+for x in 00 01 02 03 04 05 06 07 08 09 0a
 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
 
-echo Removing log files
+echo Removing old databases
 rm -f ./data/*
 
-for x in 00 01 02 03 04 05 06 07 08
+for x in 00 01 02 03 04 05 06 07 08 09
 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