Advertisement
abeksis

sdfsfd

Oct 16th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2. chdir("/home/aviabeksis/");
  3.  
  4. $backupName = "backups/".date("Y.m.d-H.m")."/backup_aviabeksis.zip";
  5. $folders = Array("scripts"=>0,"public_html"=>1,);
  6.  
  7. //$dont_save = Array("zip");
  8.  
  9. $zip = new ZipArchive;
  10.  
  11. if ($zip->open($backupName, ZIPARCHIVE::CREATE )!==TRUE)
  12. exit("cannot open <$archive_file_name>\n");
  13.  
  14. echo "Saving into $backupName ... \n";
  15.  
  16. foreach ($folders as $dir=>$sub){
  17. echo "\n\tStarting at folder : ".$dir;
  18.  
  19. // Create recursive directory iterator
  20. $files = new RecursiveIteratorIterator(
  21. new RecursiveDirectoryIterator($dir),
  22. RecursiveIteratorIterator::LEAVES_ONLY
  23. );
  24.  
  25. foreach ($files as $name => $file) {
  26. $ext = pathinfo($file, PATHINFO_EXTENSION);
  27.  
  28. if (in_array($ext,$dont_save) || basename($file)==".." || basename($file)==".")
  29. continue;
  30.  
  31. if (((substr_count($dir,"/")+1)<substr_count($file,"/")) && !$sub)
  32. continue;
  33.  
  34. //echo "\n".$name." - ".$ext." - ".basename($file);
  35. $filePath = $file->getRealPath();
  36. $zip->addFile($file->getRealPath(),$file);
  37. }
  38. }
  39. $zip->close();
  40. echo "\n";
  41. exit;
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement