Python写的一个简单的备份程序

Python写的一个简单的备份程序。

#!/usr/bin/python
#
 Filename: backup_ver1.py
#
 backup.py
import os
import time

source = ['D:\\Python\\RFC']
target_dir = 'D:\\Python\\backup\\'
target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'
zip_command = '''"C:\\Program Files\\WinRAR\\rar.exe" a %s %s''' % (target, ' '.join(source))
print zip_command
# Run the backup
if os.system(zip_command) == 0:
    print 'Successful backup to', target
else
    print 'Backup FAILED', target



posted @ 2012-01-21 10:36  wenanry  阅读(362)  评论(0编辑  收藏  举报