title: Backup Entire Website Using PHP
body: <p>Using PHP, I am developing a CMS. This needs to support website backups.</p>
  
  <p>Musts:</p>
  
  <ul>
  <li>Compressed ZIP Folders</li>
  <li>Must work on at least Linux and Windows</li>
  <li>Must work on PHP 5.0, PHP 4 would be nice</li>
  <li>I just need a function/class, don't link me open-source software as I need to do this my self</li>
  <li>CMS does not need MySQL backups as it is XML powered</li>
  </ul>
  
  <p>I've already checked into ZipArchive in PHP. Here is all I got so far. However when I try to go to the ZIP file on the server that it says it created, I get a 404? It isn't working and I don't know why.</p>
  
  <pre><code>&lt;?php
      $filename = CONTENT_DIR . 'backups/' . date( 'm-d-Y_H-i-s' ) . '.zip';
  
      if ( $handle = opendir( ABS_PATH ) ) {
          $zip = new ZipArchive();
  
          if ( $zip-&gt;open( $filename, ZIPARCHIVE::CREATE ) !== true ) {
              exit( "cannot open &lt;$filename&gt;\n" );
          }
  
          $string = '';
          while ( ( $file = readdir( $handle ) ) !== false ) {
              $zip-&gt;addFile( $file );
              $string .= "$file\n&lt;br&gt;";
          }
          closedir( $handle );
          $string .= "Status of the Zip Archive: " . $zip-&gt;status;
          $string .= "&lt;br&gt;System status of the Zip Archive: " . $zip-&gt;statusSys;
          $string .= "&lt;br&gt;Number of files in archive: " . $zip-&gt;numFiles;
          $string .= "&lt;br&gt;File name in the file system: " . $zip-&gt;filename;
          $string .= "&lt;br&gt;Comment for the archive: " . $zip-&gt;comment;
          $zip-&gt;close();
          echo $string;
      }
  ?&gt;
  </code></pre>