zoukankan      html  css  js  c++  java
  • Python 学习笔记: 备份工具

     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 
  • 相关阅读:
    IDEA搭建普通java项目
    反射的学习
    解决Eclipse中文文档注释错位-处女座的悲哀!
    maven私服的搭建
    Springboot简介01
    git初识
    Servlet学习系列1
    搭建和启动javaWeb项目
    IDEA快捷键使用说明
    1.6 比较、掩码和布尔逻辑
  • 原文地址:https://www.cnblogs.com/mobile/p/1371978.html
Copyright © 2011-2022 走看看