dump mysql metadata

This commit is contained in:
Peter Hormanns 2013-03-16 16:09:01 +01:00
parent 54c4c1f57b
commit 4d76649929

View File

@ -29,12 +29,10 @@ function shadowdump(pac) {
+ "|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) {
@ -129,7 +127,7 @@ if (pacs.length == 1 && hive != 'undef') {
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 @@ if (pacs.length == 1 && hive != 'undef') {
}
file.close();
shadowdump(pacname);
mysqlpasswddump(pacname);
mysqlaclsdump(pacname);
pgsqlpasswddump(pacname);
} else {
print('run as pac-owner!\n');