Test system Environment Windows 2003 python 2.5.1 MySQL 5.0.1
Should only apply to win because the CMD is invoked.
Incremental backups, because the database is small.
Back with the need to add self-test, 5 days before the automatic deletion.
#!/usr/bin/env python
#encoding =utf-8
#Mysql Auto Backup
#Author: Vane
Import OS, sys, datetime
Reload (SYS)
Sys.setdefaultencoding (' Utf-8 ')
Backup_path = "" "D:\\mysql_backup_files" ""
Dbhost = "localhost"
dbname = "dabatase name" # database name
Dbuser = "root" # User name
DBUSERPW = "123456" # Password
Dbcharset = ' UTF8 ' # output file encoding, default UTF8
now = str (Datetime.datetime.now ()) [: 10]
Backup_command = "" "Mysqldump-b%s-h%s-u%s-p%s--default_character-set=%s--opt>%s\dbbackup_%s_%s.sql \ n "" "% (dbname, Dbhost, Dbuser, DBUSERPW, Dbcharset, Backup_path, dbname, now)
A, B = os.popen2 (' cmd ')
A.write (Backup_command)
A.close ()
B.read ()
B.close ()
Print "done!"