Python backup脚本

#!/usr/bin/python

import os
import time

source=['/root/perl-demo','/root/perl-gongju']
target_dir='/root/backup/'
target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
zip_command="zip -qr '%s' %s" % (target,' '.join(source))
if os.system(zip_command)==0:
    print 'OK!',target
else:
    print 'NO'

 

posted @ 2013-03-05 17:41  墨迹哥's  阅读(188)  评论(0编辑  收藏  举报