Create Multipart zip


Joined: 2010-04-09
Posts: 53
Posted: Mon, 2011-08-22 04:36

So I am trying to figure out a good way to backup my album every so often and I wrote this script. I don't have shell access so I am limited to the powers of PHP. Problem is my site is pretty big (10 gigs or so) and so it would be better if I could create a multipart zip instead of just one big one. But I cannot find any documentation anywhere on how to create a multi part zip. Also it doesn't need to be a zip, just any compressed file type.


echo "hello";

// increase script timeout value
ini_set('max_execution_time', 990000);
// create object
$zip = new ZipArchive();

// open archive 
if ($zip->open('', ZIPARCHIVE::CREATE) !== TRUE) {
    die ("Could not open archive");

// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("gal3"));

// iterate over the directory
// add each file found to the archive
foreach ($iterator as $key=>$value) {
    $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");        
    echo realpath($key);

// close and save archive
echo "Archive created successfully.";