Re: Patch for review: "Handle InnoDB tables in copy-backup.py"



On Sun, Aug 09, 2009 at 02:59:11PM -0400, Owen Taylor wrote:
>  # Backup!
> +def shell_quote(s):
> +    return "'" + s.replace("'", "'\\''") + "'"

Insure! Not acceptable for a script run by root, even if impact is
minimal.

>  for db in dbs:
> -    os.spawnlp(os.P_WAIT, 'mysqlhotcopy', 'mysqlhotcopy', '--quiet', '--allowold', db, '/var/lib/mysql-backup')

Better to use subprocess.

> +    table_status = os.popen("mysql --batch -e 'show table status' %s" % shell_quote(db), 'r')

Better to use subprocess

> +        os.spawnlp(os.P_WAIT, 'mysqlhotcopy', 'mysqlhotcopy', '--quiet', '--allowold', db, '/var/lib/mysql-backup')

Better to use subprocess

> +        os.spawnlp(os.P_WAIT, 'sh', 'sh', '-c',
> +                  "mysqldump --single-transaction %s | gzip -c > %s" % (shell_quote(db), shell_quote(outfile)))

Use subprocess. You can pipe things together.

-- 
Regards,
Olav


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]