Copy codeThe Code is as follows:
#! /Usr/bin/env python
# Filename: backup_ver1.py
Import OS
Import time
#1. The files and directories to be backed up are specified in a list.
# Source = ['/home/swaroop/byte','/home/swaroop/bin']
Source = ['d: \ FileCopier \ *. * ', 'd: \ jeecms_doc \ *. *']
# If you are using Windows, use source = [r 'C: \ users', r 'd: \ work'] or something like that
#2. The backup must be stored in a main backup directory
# Target_dir = '/mnt/e/backup/' # Remember to change this to what you will be using
Target_dir = 'e: \ temp \ '# Remember to change this to what you will be using
#3. The files are backed up into a zip file
#4. The name of the zip archive is the current date and time
Target1_target_dir1_time.strftime('policy?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'