复制代码代码如下:
#!/usr/bin/env python
# Filename: backup_ver1.py
import os
import time
# 1. The files and directories to be backed up are specified in a list.
#source=['/home/swaroop/byte','/home/swaroop/bin']
source=['D:\\FileCopier\\*.*','D:\\jeecms_doc\\*.*']
# If you are using Windows, use source=[r'C:\Documents',r'D:\Work'] or something like that
# 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 using
target_dir='E:\\temp\\' #Remember to change this to what you will be using
# 3. The files are backed up into a zip file
# 4. The name of the zip archive is the current date and time
target=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="rar a " + target + ' '.join(source)
# Run the backup
if os.system(zip_command)==0:
print 'Successful backup to',target
else:
print 'Backup FAILED'
您可能感兴趣的文章:
Python实现全局变量的两个解决方法
打印出python 当前全局变量和入口参数的所有属性
Python中文件遍历的两种方法
python教程之用py2exe将PY文件转成EXE文件
python实现文件分组复制到不同目录的例子
Python实现多线程下载文件的代码实例
python读取浮点数和读取文本文件示例
python使用内存zipfile对象在内存中打包文件示例
python抓取网页图片并放到指定文件夹
在python的WEB框架Flask中使用多个配置文件的解决方法
python实现跨文件全局变量的方法
QQ空间 搜狐微博 人人网 开心网 百度搜藏更多
Tags:windows python rar命令
复制链接收藏本文打印本文关闭本文返回首页
上一篇:Python中使用动态变量名的方法
下一篇:python实现跨文件全局变量的方法
相关文章
2011-05-05python中将阿拉伯数字转换成中文的实现代码
2011-05-05python访问纯真IP数据库的代码
2009-11-11Python+Django在windows下的开发环境配置图解
2008-10-10Python转码问题的解决方法
2013-03-03python局部赋值的规则
2013-12-12python多线程http下载实现示例
2008-07-07py中的目录与文件判别代码
2013-11-11python聊天程序实例代码分享
2014-06-06测试、预发布后用python检测网页是否有日常链接
2014-03-03Python continue语句用法实例
文章评论
最 近 更 新
videocapture库制作python视频高速传输程
Python 调用VC++的动态链接库(DLL)
python抓取某汽车网数据解析html存入exce
从零学python系列之浅谈pickle模块封装和
python判断、获取一张图片主色调的2个实例
布同 Python中文问题解决方法(总结了多位
Python常见文件操作的函数示例代码
python用字典统计单词或汉字词个数示例
pycharm 使用心得(三)Hello world!
Python开发WebService系列教程之REST,web
热 点 排 行
Python入门教程 超详细1小时学会
python 中文乱码问题深入分析
比较详细Python正则表达式操作指
Python字符串的encode与decode研
Python open读写文件实现脚本
Python enumerate遍历数组示例应
Python 深入理解yield
Python+Django在windows下的开发
python 文件和路径操作函数小结
python 字符串split的用法分享