diff options
Diffstat (limited to 'rpkid')
-rw-r--r-- | rpkid/tests/sql-dumper.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/rpkid/tests/sql-dumper.py b/rpkid/tests/sql-dumper.py index cff62d4f..e4bb1a28 100644 --- a/rpkid/tests/sql-dumper.py +++ b/rpkid/tests/sql-dumper.py @@ -3,7 +3,7 @@ Dump backup copies of SQL tables used by these programs. $Id$ -Copyright (C) 2009--2010 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 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 @@ -18,7 +18,9 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import subprocess, rpki.config +import subprocess +import rpki.config +from rpki.mysql_import import MySQLdb cfg = rpki.config.parser(None, "yamltest", allow_missing = True) @@ -28,5 +30,14 @@ for name in ("rpkid", "irdbd", "pubd"): password = cfg.get("%s_sql_password" % name, "fnord") cmd = ["mysqldump", "-u", username, "-p" + password, "--databases"] - cmd.extend("%s%d" % (name[:4], i) for i in xrange(12)) + + db = MySQLdb.connect(user = username, passwd = password) + cur = db.cursor() + + cur.execute("SHOW DATABASES") + cmd.extend(r[0] for r in cur.fetchall() if r[0][:4] == name[:4] and r[0][4:].isdigit()) + + cur.close() + db.close() + subprocess.check_call(cmd, stdout = open("backup.%s.sql" % name, "w")) |