[Tutor] Zip-ing files/folders - collecting opinions

Magnus Lycka magnus@thinkware.se
Wed Jan 29 13:58:03 2003


At 23:19 2003-01-28 -0500, Branimir Petrovic wrote:
>My archiving script must be able to compress large
>10 GB+ Oracle dump files (among other things).

Can't you convince Oracle to spew out more and smaller
files instead? 10GB files aren't so funny to play
with.

Another option is to split the file as you read it,
and save compressed parts.

chunksize = 100000000

f = file('oracle.dump', 'rb')
i = 0
while 1:
         data = f.read(chunksize)
         if not data:
                 break
         myWriteToZipFile(data, 'mydump_%04i.zip' % i)


To restore, you'd just do:

fileNames=glob.glob('mydump*.zip')
fileNames.sort()
f = file('restored.dump', 'rb')

for fn in fileNames:
         data = myUnZipFromFile(fn)
         w.write(data)


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se