python备份文件以及mysql数据库的脚本代码
2013-06-10 00:00
881 查看
#!/usr/local/python import os import time import string source=['/var/www/html/xxx1/','/var/www/html/xxx2/'] target_dir='/backup/' target=target_dir+time.strftime('%Y%m%d') zip_comm='zip -r %s %s'%(target," ".join(source)) target_database=['DB_name1','DB_name2'] sql_user='root' sql_pwd='xxx' if os.system(zip_comm) == 0: print 'file backup Success is:',target #if python version is 3.x ,print('file backup Success is:',target) else: print 'file backup failed!' for database_name in target_database: target_sql=target_dir+database_name+time.strftime('%Y%m%d')+'.sql' sql_comm='/usr/local/mysql/bin/mysqldump -u %s -p%s %s > %s'%(sql_user,sql_pwd,database_name,target_sql) if os.system(sql_comm) == 0: print database_name,'is backup seccess!' else: print database_name,'is backup Failed!!'
相关文章推荐
- python备份文件以及mysql数据库的脚本代码
- selenium+python关于登录的脚本代码,使用了读取excel以及向excel中写入测试结果的方法
- Python测试用例生成脚本(合并相应单元格以及写入单行数据)代码实例
- selenium+python关于登录的脚本代码,使用了读取excel以及向excel中写入测试结果的方法
- Python测试用例生成脚本(合并相应单元格以及写入单行数据)代码实例
- python读取word文档,插入mysql数据库的示例代码
- Python脚本调用C#代码数据交互示例(hello world)
- 使用python的列表解析以及函数式计算来简化代码
- PyQt 连接MySql数据库,C++代码转Python3代码
- Python连接以及操作MySQL数据库详解
- python脚本按表备份MySQL数据库
- Python 生产环境MySQL数据库增量备份脚本
- python中wx将图标显示在右下角的脚本代码
- python通过elixir包操作mysql数据库实例代码
- mysql数据库的连接以及增删改查Java代码实现(PreparedStatement版)
- python写代码生成脚本
- Linux自动备份MySQL数据库脚本代码
- 选择MySQL数据库的命令以及PHP脚本下的操作方法
- Python复制目录结构脚本代码分享
- Python 包、模块、类以及代码文件和目录的一种管理方案