Python备份脚本——版本一(Windows)
来源:互联网 发布:常见软件项目风险 编辑:程序博客网 时间:2024/06/05 10:00
参照python简明教程中的示例改写的windows环境下备份程序
压缩工具使用7zip的命令行版本
相关命令查阅7zip附加内容 http://sparanoid.com/lab/7z/
要求:
需要备份的文件和目录由一个列表指定。
备份应该保存在主备份目录中。
文件备份成一个zip文件。
zip存档的名称是当前的日期和时间。
import osimport time# 1. The files and directories to be backed up are specified in a list.# source = ['/home/swaroop/byte', '/home/swaroop/bin']# If you are using Windows, use source = [r'C:\Documents', r'D:\Work'] or something like thatsource = [r'C:\Python\test']# 2. The backup must be stored in a main backup directory# target_dir = '/mnt/e/backup/' # Remember to change this to what you will be usingtarget_dir = r'C:\Python\test2\\'# 3. The files are backed up into a zip file.# 4. The name of the zip archive is the current date and timetarget = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'# 5. We use the zip command (in Unix/Linux) to put the files in a zip archive# zip_command = "zip -qr '%s' %s" % (target, ' '.join(source))zip_command = r"""D:\Progra~1\7-Zip\7z.exe a %s %s""" % (target, ''.join(source))# Run the backupif os.system(zip_command) == 0:print 'Successful backup to', targetelse:print 'Backup FAILED'
- Python备份脚本——版本一(Windows)
- Python脚本 —Windows下文件备份
- PYTHON教程中“编写一个Python脚本”版本一的windows版本
- Python在Windows下实现文件备份 脚本程序 版本1
- windows oracle中统一备份脚本
- python备份mysql数据库脚本一枚
- 【Python学习】--Windows下实现备份的Python脚本
- windows和linux下的python备份脚本
- Python脚本实现windows下文件的备份
- windows和ubuntu下使用python写备份脚本
- 使用python在windows 下 编写 自动备份脚本
- windows和ubuntu下使用python写备份脚本
- Windows环境下python备份脚本编写(二)
- windows rman备份脚本
- windows脚本备份
- 一个Python备份脚本
- python备份数据脚本
- python 备份mysql脚本
- JVM学习之:类加载的过程总结
- DM6446相关
- 结构体与类
- error C2276: “&”: 绑定成员函数表达式上的非法操作
- Spring AOP声明式事务异常回滚
- Python备份脚本——版本一(Windows)
- ranlib的作用
- VC中#pragma warning指令
- 信号概念
- u-boot for s3c44b0x 移植心得
- 一个加减乘除的词法分析器
- Graphviz 拓扑图
- Struts2+hibernate+spring 配置文件中scope="prototype"的作用 .
- 建立Ad Hoc 无线连接