[Tutor] How to call mysqlcommand in Python , "mysqldump for backup "
John Joseph
jjk_saji at yahoo.com
Wed Dec 28 10:03:56 CET 2005
--- nephish <nephish at xit.net> wrote:
> ooh ooh, i know this one, i have python do this for
> me every day !
>
> target_dir = '/path/to/where/you/want/to/dump'
>
> os.system("mysqldump --add-drop-table -c -u user
> -ppassword database
> table > "+target_dir+"/table.bak.sql")
>
> dont forget the p in front of your password !
>
> hope this helps
>
>
Hi it helped me a lot ,
I did my script like this for backing my zabbix
database
import os, time
# difine the target directory
target_dir = '/home/john/backup/z-b-weekly/zabbix'
# in the formar year-month-day-hours-minute-secound
# uses time module
today = time.strftime('%Y-%m-%d-%H-%M-%S')
# For testing purpose only I had kept %M %S , we can
remove it later
now = target_dir + today
os.system("mysqldump -u root -pjohn zabbix >
"+now+" " )
Thanks A LOT
Joseph
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
More information about the Tutor
mailing list