首页 > 编程语言 > 详细

Python写的备份目录文件的脚本

时间:2015-05-27 15:59:51      阅读:223      评论:0      收藏:0      [点我收藏+]

#!/usr/bin/python

# -*- coding: utf-8 -*-

#filename back.py

#author superchen


import os

import time

source =‘/home/shiyanlou/Documents/‘

target_dir = ‘/home/shiyanlou/Desktop‘

target = target_dir+time.strftime(‘%Y-%m-%d-%H-%M-%S‘)+‘.zip‘

zip_command = "zip -qr %s %s" %(target,‘‘.join(source))

#q命令是安静运行r命令是递归的执行

if os.system(zip_command)==0:

    print ‘sucessful backup‘

else:

    print "backup failed"


Python写的备份目录文件的脚本

原文:http://leizhu.blog.51cto.com/3758740/1655639

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!