-
-
Save mkudenko/8117a0eca7b8e0496c70 to your computer and use it in GitHub Desktop.
Revisions
-
Marvin Menzerath revised this gist
Feb 28, 2014 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <?php /* * PHP: Recursively Backup Files & Folders to ZIP-File * (c) 2012-2014: Marvin Menzerath - http://menzerath.eu */ // Make sure the script can handle large folders/files @@ -14,22 +14,22 @@ // Here the magic happens :) function zipData($folder, $zipTo) { if (extension_loaded('zip')) { if (file_exists($source)) { $zip = new ZipArchive(); if ($zip->open($destination, ZIPARCHIVE::CREATE)) { $source = realpath($source); if (is_dir($source)) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST); foreach ($files as $file) { $file = realpath($file); if (is_dir($file)) { $zip->addEmptyDir(str_replace($source . '/', '', $file . '/')); } else if (is_file($file)) { $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); } } } else if (is_file($source)) { $zip->addFromString(basename($source), file_get_contents($source)); } } -
menzerath revised this gist
May 28, 2013 . 1 changed file with 24 additions and 28 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <?php /* * PHP Recursive Backup-Script to ZIP-File * (c) 2012-2013: Marvin Menzerath. (http://menzerath.eu) */ // Make sure the script can handle large folders/files @@ -14,32 +14,28 @@ // Here the magic happens :) function zipData($folder, $zipTo) { if (extension_loaded('zip') === true) { if (file_exists($source) === true) { $zip = new ZipArchive(); if ($zip->open($destination, ZIPARCHIVE::CREATE) === true) { $source = realpath($source); if (is_dir($source) === true) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST); foreach ($files as $file) { $file = realpath($file); if (is_dir($file) === true) { $zip->addEmptyDir(str_replace($source . '/', '', $file . '/')); } else if (is_file($file) === true) { $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); } } } else if (is_file($source) === true) { $zip->addFromString(basename($source), file_get_contents($source)); } } return $zip->close(); } } return false; } ?> -
menzerath revised this gist
Dec 1, 2012 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,13 +3,14 @@ * PHP Recursive Backup-Script to ZIP-File * (c) 2012: Marvin Menzerath. (http://menzerath.eu) */ // Make sure the script can handle large folders/files ini_set('max_execution_time', 600); ini_set('memory_limit','1024M'); // Start the backup! zipData('/path/to/folder', '/path/to/backup.zip'); echo 'Finished.'; // Here the magic happens :) function zipData($folder, $zipTo) { -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ <?php /* * PHP Recursive Backup-Script to ZIP-File * (c) 2012: Marvin Menzerath. (http://menzerath.eu) */ // Make sure the script can handle large folders/files ini_set('max_execution_time', 600); ini_set('memory_limit','1024M'); // Start the backup! zipData('/path/to/folder', '/path/to/backup_'.date("d.m.Y-H.i").'.zip'); echo date("d.m.Y-H.i").' - Abgeschlossen.'; // Here the magic happens :) function zipData($folder, $zipTo) { if (extension_loaded('zip') === true) { if (file_exists($source) === true) { $zip = new ZipArchive(); if ($zip->open($destination, ZIPARCHIVE::CREATE) === true) { $source = realpath($source); if (is_dir($source) === true) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST); foreach ($files as $file) { $file = realpath($file); if (is_dir($file) === true) { $zip->addEmptyDir(str_replace($source . '/', '', $file . '/')); } else if (is_file($file) === true) { $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); } } } else if (is_file($source) === true) { $zip->addFromString(basename($source), file_get_contents($source)); } } return $zip->close(); } } return false; } ?>