#!/bin/python
import os
import time
source = ['hello1.py'] /*原文件*/
#print source
target_dir = '/home/dujy/masen/rwz/back/' /*目标目录*/
#print target_dir
target = time.strftime('%Y%m%d%H%M%S') + '.tgz' /*备份文件的名字*/
#print target
zip_command = "tar -zcvf %s %s" % (target, ' '.join(source)) /*开始备份的命令*/
print zip_command
if os.system(zip_command) == 0:/*执行命令*/
print 'Successful backup to', target
else:
print 'Backup FAILED'