惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
IT之家
IT之家
Google DeepMind News
Google DeepMind News
D
Docker
J
Java Code Geeks
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 【当耐特】
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
月光博客
月光博客
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Liren

查找目录中同名的文件或者文件夹 获取设置一个字节某一个位的数值 基于JMS的数据交换既数据互操作平台的解决方案 Spring MVC基于注解的Junit测试 Spring MVC 3中关于url-pattern设成"/"后,资源访问问题 博文阅读密码验证 - 博客园 NotificationManager - Liren - 博客园 发送短信 调用系统联系人列表 MorseCodeConverter 自用留存 - Liren - 博客园 Android 给自己的类加个事件 用代码旋转屏幕 - Liren - 博客园 Android SQLiteHelper Cassandra API60 Java 代码示例 Cassandra Java 使用TimeUUIDType 转:在 CLI 中練習 Data Model asp.net 实现一个简单CAS Server - Liren Ajax跨域访问代理类,支持GET和POST方法 Python 学习笔记:需要仔细阅读一个函数
Python 学习笔记: 备份工具
Liren · 2009-01-08 · via 博客园 - Liren

 1 #!/usr/bin/python
 2 #filename:backup_ver3.py
 3 import os
 4 import time
 5 
 6 source=['/media/Work/WorkSpaces/gooapp','/media/Work/WorkSpaces/RsaTool']
 7 target_dir='/media/Work/backup/'
 8 today = target_dir + time.strftime('%Y%m%d')
 9 now = time.strftime('%H%M%S')
10 
11 comment = raw_input('Enter a comment:')
12 if len(comment) == 0:
13     target = today + os.sep + now + '.tar'
14 else:
15     target = today + os.sep + now + '_' + comment.replace(' ','_'+ '.tar'
16             
17 if not os.path.exists(today):
18     os.mkdir(today)
19     print 'Sucessfully created directory',today
20     
21 tar_command = 'tar -cvzf %s %s' % (target, ' '.join(source)) 
22 
23 if os.system(tar_command) == 0:
24     print 'Successful backup to',target
25 else:
26     print 'Backup FAILED'
27