[Tutor] Backupfile program. Help. Thanks.
Ricardo Aráoz
ricaraoz at gmail.com
Sun Sep 2 21:01:02 CEST 2007
shimon gurman wrote:
> Can someone explain to me why this program isnt working? i.e. I always get 'backup failed'?
> This is a program from byte of python tutorial and im using windows xp.
>
>
>
>
> import os, time
>
>
>
> source = ['d:\\python']
>
>
> target_directory = 'd:\\python1'
>
> target = target_directory + time.strftime('%Y%m%d_%H%M%S') + '.zip'
>
> zip_command = "zip -qr '%s' %s" % (target, ' '.join(source))
>
> print zip_command
>
>
> if os.system(zip_command) == 0:
> print 'Successful backup to', target
> else:
> print 'Backup FAILED'
>
try (I'm guessing) :
target_directory = 'd:\\python1\\'
and / or
zip_command = 'zip -qr "%s" "%s"' % (target, ' '.join(source))
(your second %s was not enclosed in ", besides it's probably better to
use " than ', can't remember right now)
Are you sure that is a '-qr' or should it be '-pr'? I can not check it
because I use 7-zip (here p would set password and r recurse directories).
More information about the Tutor
mailing list