灌溉梦想,记录脚步
« »
2011年7月17日技术合集

Python 自动备份Mysql脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python
import os
import time
 
# 连接参数
username = root
password = 123456
hostname = localhost
 
# 获取时间
filestamp = time.strftime('%Y-%m-%d')
 
# 获取数据列表并备份
database_list_command="mysql -u %s -p%s -h %s --silent -N -e 'show databases'" % (username, password, hostname)
for database in os.popen(database_list_command).readlines():
    database = database.strip()
    if database == 'information_schema':
        continue
    filename = "/backups/mysql/%s-%s.sql" % (database, filestamp)
    os.popen("mysqldump -u %s -p%s -h %s -e --opt -c %s | gzip -c > %s.gz" % (username, password, hostname, database, filename))

日志信息 »

该日志于2011-07-17 00:05由 kevin 发表在技术合集分类下, 你可以发表评论。除了可以将这个日志以保留源地址及作者的情况下引用到你的网站或博客,还可以通过RSS 2.0订阅这个日志的所有评论。

13 条评论

  1. buy androxal uk pharmacy

    buying androxal price singapore

  2. buy enclomiphene generic alternative

    how to buy enclomiphene australia pharmacy

  3. cheapest buy rifaximin retail price

    buy cheap rifaximin australia discount

  4. xifaxan mail order uk

    ordering xifaxan generic work

  5. purchase staxyn spain over the counter

    buy staxyn us pharmacies

  6. how to order avodart purchase uk

    how to order avodart buy online no prescription

  7. order flexeril cyclobenzaprine canada medicine

    how to order flexeril cyclobenzaprine purchase line

  8. buy dutasteride australia no prescription

    discount dutasteride cheap next day delivery

  9. buy cheap gabapentin uk buy over counter

    gabapentin saturday delivery

  10. medicament kamagra distribuer ses

    medicament kamagra pharmacie envoyer annuaire

  11. get fildena generic uk

    ordering fildena no rx needed

  12. purchase itraconazole american pharmacy

    how to buy itraconazole generic medications

  13. předpis kamagra cod

    100 mg kamagra

发表回复