title: PHP Recursive Backup Script
body: <p>I wrote a basic content-management system for my website, including an administration panel. I understand basic file IO as well as copying via PHP, but my attempts at a backup script callable from the script have failed. I tried doing this:</p>
  
  <pre><code>//... authentication, other functions
  for(scandir($homedir) as $buffer){
      if(is_dir($buffer)){
          //Add $buffer to an array
      }
      else{
          //Back up the file
      }
  }
  for($founddirectories as $dir){
      for(scandir($dir) as $b){
          //Backup as above, adding to $founddirectories
      }
  }
  </code></pre>
  
  <p>But it did not seem to work.</p>
  
  <p>I know that I can do this using FTP, but I want a completely server-side solution that can be accessed anywhere with sufficient authorization.</p>