备份

import math
import os
import time
__author__ = 'sun'

source=['/home/sun/byte','/home/sun/bin']
target_dir='/home/sun/backup/'
target=target_dir+time.strftime('%Y%m%H%M%S')+'.zip'
zip_command="zip -qr '%s' %s" %(target,''.join(source))
if os.system(zip_command)==0:
    print ('备份成功',target)
else:
    print('备份失败')

 

posted @ 2013-09-18 14:40  yufenghou  阅读(142)  评论(0)    收藏  举报