Python 创建文件备份
来源:互联网 发布:港股查询软件 编辑:程序博客网 时间:2024/05/17 02:44
一个简单的例子,A byte of Python的例子,利用系统自带的命令创建某些文件的备份,放入指定的目录中。
简单功能已具有,先记下,今后可以和网盘接口连接。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import
os
import
time
source
=
[
'/home/dat/python/test1'
,
'/home/dat/python/test2'
]
target_dir
=
'/home/dat/python/'
today
=
target_dir
+
time.strftime(
'%Y%m%d'
)
now
=
time.strftime(
'%H%M%S'
)
comment
=
raw_input
(
'Enter a comment:'
)
if
len
(comment)
=
=
0
:
target
=
today
+
os.sep
+
now
else
:
target
=
today
+
os.sep
+
now
+
'_'
+
comment.replace(
' '
,
'_'
)
+
'.zip'
if
not
os.path.exists(today):
os.mkdir(today)
print
'successfully created directory'
,today
tar_command
=
'tar -cvzf %s %s -X /home/dat/python/excludes.txt'
%
(target,
' '
.join(source))
if
os.system(tar_command)
=
=
0
:
print
'Success back to'
,target
else
:
print
'Back up Failed'
- Python 创建文件备份
- Python实现文件备份
- python 文件增量备份
- Python实现文件备份
- python实践,文件备份
- Python库文件地址备份
- Python 备份指定目录文件
- 使用python进行文件备份
- Python脚本-文件备份
- Python文件复制,备份,搜索
- python中的文件备份过程
- python创建xml文件
- python创建文件
- python 创建新文件
- python 创建txt文件
- Python实现文件的全备份和差异备份
- Python应用第一波:文件打包备份
- python 实战:文件备份小程序
- 【Oracle】Oracle简介
- Android中Context详解
- Hibernate大数据量处理,大量数据处理代码优化方法概念(转载)
- linux 设备驱动
- Oracle 数据库多路归档,防止单点故障
- Python 创建文件备份
- python16进制和10进制转换
- MySQL如何创建主键?Alter table add PRIMARY KEY的用法和例子
- Android控件之Spinner
- Ajax数据格式摘要
- Android学习篇章51-MediaPlayer-音频播放
- C++设计模式之七--AbstractFactory抽象工厂模型
- GCC 编译动态库和静态库
- MyBatis+MySQL 返回插入的主键ID