aboutsummaryrefslogtreecommitdiff
path: root/myrpki/sql-dumper.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2009-07-17 00:35:33 +0000
committerRob Austein <sra@hactrn.net>2009-07-17 00:35:33 +0000
commit8be91ec1161d3865eee87103dec1fd4efa710f9c (patch)
tree637fcfdc7f361f9c8f58977a3813c7395e5ae959 /myrpki/sql-dumper.py
parent9c7e9583f6cb04eb2df0e4c9a1eb33fb1e9c60c2 (diff)
Hack for backing up SQL test data
svn path=/myrpki/Makefile; revision=2629
Diffstat (limited to 'myrpki/sql-dumper.py')
-rw-r--r--myrpki/sql-dumper.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/myrpki/sql-dumper.py b/myrpki/sql-dumper.py
new file mode 100644
index 00000000..ac98e827
--- /dev/null
+++ b/myrpki/sql-dumper.py
@@ -0,0 +1,38 @@
+"""
+Dump backup copies of SQL tables used by these programs.
+
+$Id$
+
+Copyright (C) 2009 Internet Systems Consortium ("ISC")
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+"""
+
+import subprocess, ConfigParser
+
+for name in ("rpkid", "irdbd", "pubd"):
+
+ try:
+ cfg = ConfigParser.RawConfigParser()
+ cfg.read("%s.conf" % name)
+ username = cfg.get(name, "sql-username")
+ password = cfg.get(name, "sql-password")
+ database = cfg.get(name, "sql-database")
+
+ except:
+ print "Cleaner couldn't read %s config file, ignoring" % name
+ continue
+
+ cmd = ["mysqldump", "-u", username, "-p" + password, "--databases", database]
+ cmd.extend("%s%d" % (database, i) for i in xrange(12))
+ subprocess.check_call(cmd, stdout = open("backup.%s.sql" % name, "w"))