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
# 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
print ' Backup FAILED ', target