Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- chdir("/home/aviabeksis/");
- $backupName = "backups/".date("Y.m.d-H.m")."/backup_aviabeksis.zip";
- $folders = Array("scripts"=>0,"public_html"=>1,);
- //$dont_save = Array("zip");
- $zip = new ZipArchive;
- if ($zip->open($backupName, ZIPARCHIVE::CREATE )!==TRUE)
- exit("cannot open <$archive_file_name>\n");
- echo "Saving into $backupName ... \n";
- foreach ($folders as $dir=>$sub){
- echo "\n\tStarting at folder : ".$dir;
- // Create recursive directory iterator
- $files = new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator($dir),
- RecursiveIteratorIterator::LEAVES_ONLY
- );
- foreach ($files as $name => $file) {
- $ext = pathinfo($file, PATHINFO_EXTENSION);
- if (in_array($ext,$dont_save) || basename($file)==".." || basename($file)==".")
- continue;
- if (((substr_count($dir,"/")+1)<substr_count($file,"/")) && !$sub)
- continue;
- //echo "\n".$name." - ".$ext." - ".basename($file);
- $filePath = $file->getRealPath();
- $zip->addFile($file->getRealPath(),$file);
- }
- }
- $zip->close();
- echo "\n";
- exit;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement