Copy CodeThe code is as follows:
#!/usr/bin/env python
# Filename:backup_ver1.py
Import OS
Import time
# 1. The files and directories to is backed up is specified in a list.
#source =['/home/swaroop/byte ', '/home/swaroop/bin ']
source=[' d:\\filecopier\\*.* ', ' d:\\jeecms_doc\\*.* ']
# If you're using Windows, use source=[r ' C:\Documents ', R ' D:\Work ') or something like that
# 2. The backup must is stored in a main backup directory
#target_dir = '/mnt/e/backup/' #Remember to the
Target_dir= ' e:\\temp\\ ' #Remember to the change
# 3. The files is backed up into a zip file
# 4. The name of the ZIP archive is the current date and time
Target=target_dir+time.strftime ('%y%m%d%h%m%s ') + '. Zip '
# 5. We Use the Zip command (in unix/linux) to put the files in a zip archive
#zip_command = "Zip-qr '%s '%s"% (target, ". Join (source))
zip_command= "rar a" + target + ". Join (source)
# Run The Backup
If Os.system (Zip_command) ==0:
print ' successful backup to ', target
Else
print ' Backup FAILED '