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

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
罗磊的独立博客
B
Blog
博客园_首页
A
About on SuperTechFans
有赞技术团队
有赞技术团队
V
V2EX
U
Unit 42
I
InfoQ
IT之家
IT之家
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
H
Help Net Security

博客园 - 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