From 4d766499295bd28a79094f874810b439ca1c5b90 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Sat, 16 Mar 2013 16:09:01 +0100
Subject: [PATCH] dump mysql metadata

---
 hsarjcli/scripting/package_dump.js |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/hsarjcli/scripting/package_dump.js b/hsarjcli/scripting/package_dump.js
index 134a87a..628747e 100644
--- a/hsarjcli/scripting/package_dump.js
+++ b/hsarjcli/scripting/package_dump.js
@@ -29,14 +29,12 @@
 			+ "|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump;
 	runbash(cmd);
 }
-function mysqlpasswddump(pac) {
+function mysqlaclsdump(pac) {
 	var dump = "/home/pacs/" + pac + "/.bak/mysql_passwd.gz";
-	var sql = "select concat('update user set Password=\\\'', Password, '\\\' where User=\\\'', User, '\\\';')"
-	       	+ " as update_passwd from user where user like '" + pac + "%';";
-	var cmd = "( ( echo \"" + sql + "\"|mysql mysql ) ; echo \"flush privileges;\" )"
-			+ "|sed '1d'|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump;
+	var cmd = "mysqldump --no-create-db --skip-opt --no-create-info --replace --where=\"user like '" + pac + "%'\" mysql --tables user > " + dump
+		+ " && mysqldump --no-create-db --skip-opt --no-create-info --replace --where=\"db like '" + pac + "%'\" mysql --tables db tables_priv proc >>" + dump;
 	runbash(cmd);
-}
+} 
 function pgsqlpasswddump(pac) {
 	var dump = "/home/pacs/" + pac + "/.bak/pgsql_passwd.gz";
 	var cmd = "export PGUSER=postgres; pg_dumpall -r | grep ^ALTER | grep " + pac
@@ -129,7 +127,7 @@
 		    file.write('target: [\n');
 		    if (addresses[idx]['target']) {
 				for (jdx=0; jdx<addresses[idx]['target'].length; jdx++) {
-			    	file.write('     "' + addresses[idx]['target'][jdx] + '",\n');
+			    	file.write('     \'' + addresses[idx]['target'][jdx] + '\',\n');
 				}
 			}
 		    file.write('  ]\n');
@@ -207,7 +205,7 @@
 	}
 	file.close();
 	shadowdump(pacname);
-	mysqlpasswddump(pacname);
+	mysqlaclsdump(pacname);
 	pgsqlpasswddump(pacname);
 } else {
     print('run as pac-owner!\n');

--
Gitblit v1.9.1