Python Script to backup a directory

Posted by rgolwalkar on Stack Overflow See other posts from Stack Overflow or by rgolwalkar
Published on 2010-03-13T10:45:01Z Indexed on 2010/03/13 10:55 UTC
Read the original article Hit count: 315

Filed under:
|
|
|

Filename:backup_ver1

import os import time

1 Using list to specify the files and directory to be backed up

source = r'C:\Documents and Settings\rgolwalkar\Desktop\Desktop\Dr Py\Final_Py'

2 define backup directory

destination = r'C:\Documents and Settings\rgolwalkar\Desktop\Desktop\PyDevResourse'

3 Setting the backup name

targetBackup = destination + time.strftime('%Y%m%d%H%M%S') + '.rar'

rar_command = "rar.exe a -ag '%s' %s" % (targetBackup, ''.join(source))

i am sure i am doing something wrong here - rar command please let me know

if os.system(rar_command) == 0: print 'Successful backup to', targetBackup else: print 'Backup FAILED'

O/P:- Backup FAILED

winrar is added to Path and CLASSPATH under Environment variables as well - anyone else with a suggestion for backing up the directory is most welcome

© Stack Overflow or respective owner

Related posts about python

Related posts about backup