Tarfile module error

B

Beowulf

Hello,

I'm using Python to automate admin tasks on my job. We use Windoze
2000 as desktop platform. When executing this daily backup scripts I
get the following error:

Traceback (most recent call last):
File "C:\UTILS\backup.py", line 8, in ?
TarFileBackup = tarfile.open(NewBackupFilename, 'w:bz2')
File "C:\Python23\lib\tarfile.py", line 875, in open
return func(name, filemode, fileobj)
File "C:\Python23\lib\tarfile.py", line 980, in bz2open
raise ReadError, "not a bzip2 file"
tarfile.ReadError: not a bzip2 file
----
Here's the code:
----
import tarfile
from datetime import datetime

DirBackup = r'\\skpdc01\Backups'
DirOrig = r'C:\WUTemp'

NewBackupFilename = DirBackup + '\\' + '%s' % (datetime.today()) +
'.tar.bz2'
TarFileBackup = tarfile.open(NewBackupFilename, 'w:bz2')
TarFileBackup.add(DirOrig)
TarFileBackup.close()
----
What am I doing wrong? From the error message I gues the library is
expecting the bzip file to exists, but I am explicitly open it whit
'w:bz2' Any ideas?

Thanks.
 
K

Kartic

Your NewBackupFilename contains ":" which is not a valid character in a
filename in Windows.

You could do something like this:I changed your DirBackup to 'C:\skpdc01\Backups'

Thanks,
--Kartic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top