* The EUID index is now built, and replication checks are being performed
[citadel.git] / citadel / database_cleanup.sh
1 #!/bin/bash
2
3 die () {
4         echo Exiting.
5         exit 1
6 }
7
8
9 # If we're on an Easy Install system, use our own db_ tools.
10 #
11 if [ -x /usr/local/ctdlsupport/bin/db_dump ] ; then
12         export PATH=/usr/local/ctdlsupport/bin:$PATH
13 fi
14
15 # Ok, let's begin.
16 #
17 clear
18 cat <<!
19
20 Citadel Database Cleanup
21 ---------------------------
22
23 This script exports, deletes, and re-imports your database.  If you have
24 any data corruption issues, this program may be able to clean them up for you.
25  
26 Please note that this program does a Berkeley DB dump/load, not a Citadel
27 export.  The export files are not generated by the Citadel export module.
28
29 WARNING #1:
30   MAKE A BACKUP OF YOUR DATA BEFORE ATTEMPTING THIS.  There is no guarantee
31   that this will work!
32
33 WARNING #2:
34   citserver must NOT be running while you do this.
35
36 WARNING #3:
37   Please try "db_recover -c" from the data/ directory first.  Use this tool
38   only if that one fails to fix your problem.
39
40 WARNING #4:
41   You must have an amount of free space on your disk that is at least twice
42   the size of your database.
43
44 !
45
46 echo -n "Do you want to continue? "
47
48 read yesno
49 case "$yesno" in
50         "y" | "Y" | "yes" | "YES" | "Yes" )
51                 echo 
52                 echo DO NOT INTERRUPT THIS PROCESS.
53                 echo
54         ;;
55         * )
56                 exit
57 esac
58
59 for x in 00 01 02 03 04 05 06 07 08 09 0a
60 do
61         filename=cdb.$x
62         echo Dumping $filename
63         db_dump -h ./data $filename >/tmp/CitaDump.$x || die
64         rm -f ./data/$filename
65 done
66
67 echo Removing old databases
68 rm -f ./data/*
69
70 for x in 00 01 02 03 04 05 06 07 08 09
71 do
72         filename=cdb.$x
73         echo Loading $filename
74         db_load -h ./data $filename </tmp/CitaDump.$x && {
75                 rm -f /tmp/CitaDump.$x
76         }
77 done
78
79 echo 
80 echo Dump/load operation complete.  Start your Citadel server now.
81 echo