diff options
| author | bwarsaw | 1999-03-21 20:29:17 +0000 |
|---|---|---|
| committer | bwarsaw | 1999-03-21 20:29:17 +0000 |
| commit | 5b5e6e4c7d12d8da3c44319d59a0e9882d448f63 (patch) | |
| tree | 5df57f3e5c807fbbade618bad7b3aaa9307e8b6a | |
| parent | 3675f78c651c889a7f5d03d4629f502b48f1cbcc (diff) | |
| download | mailman-5b5e6e4c7d12d8da3c44319d59a0e9882d448f63.tar.gz mailman-5b5e6e4c7d12d8da3c44319d59a0e9882d448f63.tar.zst mailman-5b5e6e4c7d12d8da3c44319d59a0e9882d448f63.zip | |
Script to check the state of a list's database file
| -rwxr-xr-x | bin/check_db | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/bin/check_db b/bin/check_db new file mode 100755 index 000000000..ca157325b --- /dev/null +++ b/bin/check_db @@ -0,0 +1,70 @@ +#! /usr/bin/env python + +"""Check the raw config.db for a mailing list. +Also check the config.db.last if the live file is corrupted. + +Usage: %(program)s listname +""" + +import sys +import os +import marshal +import paths +import Mailman.mm_cfg + +program = sys.argv[0] + +def testfile(filename): + try: + fp = open(filename) + except IOError, (code, msg): + print filename, 'cannot be opened:\n\t', msg + return 1 + else: + try: + d = marshal.load(fp) + except (EOFError, ValueError, TypeError), msg: + print filename, 'is corrupted:\n\t', msg + return 1 + else: + print filename, 'is fine' + return 0 + + +def main(): + if len(sys.argv) == 2: + listname = sys.argv[1] + else: + print __doc__ % globals() + sys.exit(1) + + listpath = os.path.join(Mailman.mm_cfg.LIST_DATA_DIR, listname) + configdb = os.path.join(listpath, 'config.db') + lastdb = os.path.join(listpath, 'config.db.last') + + origbad = testfile(configdb) + backupbad = testfile(lastdb) + + if origbad and not backupbad: + print """ +***** ALERT ***** +The original database file is corrupt, but the backup seems fine. +Consider copying + %(lastdb)s +to + %(configdb)s +however, you may lose some data.""" % locals() + elif origbad and backupbad: + print """ +***** ALERT ***** +Both the original database file and the backup seem +corrupted. You will probably need to recover both + %(configdb)s +and + %(lastdb)s +from a system backup, or remove the list `%(listname)s' and +re-create it from scratch.""" % locals() + + +if __name__ == '__main__': + main() |
