备份

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('备份失败')
原文地址:https://www.cnblogs.com/yufenghou/p/3328406.html