标签:python备份脚本
#!/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