Automatic local download of Files for Backup


I’m running a nightly CRON job to back up by database just in case somebody gets into it and decides to have some fun. In addition, I’ve got a local copy of my site. However, there are a few dynamically user created folders that I’d also like to backup just in case somebody wreaks havoc on my site. Is there any easy way to set up some sort of automatic local back-up that “gets” a set of folders, the folder structure, and the files, aka the way that I could do it non-automatically through Dreamweaver?

Thank you,


PS I don’t want to abuse this forum, so just FYI I posted a similar post in the PHP forum hoping to get a PHP solution. Since nobody has responded there, my guess is that a PHP solution would be pretty involved. However, please feel free to delete if it isn’t appropriate to ask this in the more general setting! (:

Well if you have SSH access you could setup a routine to TAR and GZIP the whole website directory, via a task scheduler. May be possible to do this via local system that would SSH into the server and then use FTP via SSH to download the TAR.GZ file. However, I’m unaware of how to do this at the moment.

Thanks for the info!

Am I being a little crazy to want to do this? I mean…my provider backs things up as well, I’m assuming…

Hey, yes, you can do this, depending on how much access you have to the server, and then what resources you have to backup to. Here is a system I have just setup.

Webserver (where I have root) > readyNAS local storage (in my home)

  • Install the root plugin on the readyNAS, allowing root to ssh into.
  • Open firewall on home router to ONLY allow external access from Webserver IP
  • Get Webserver public key text, in /root/.ssh/
  • Copy this text to /root/.ssh/authorized_keys on readyNAS

Now Webserver can SSH into readyNAS without having to login, just using the public key. Next, create a shell (or PHP or whatever) script to backup all the files you want i.e

  • Turn off services, like apache2, mysqld
  • rsync backup the mysql folder + config files
  • rsync backup the apache config folder
  • rsync backup anything else of note
  • Turn on services to resume normal server operation

The rsync is from my webserver, to the readyNAS. I use -a for archive mode, so its compressed, and incremental. I use a php script, run daily with CRON to define the root backup folder, using days of week. So we have a 7 day rolling incremental backup.

This is a pretty secure system i.e. ssh between to servers, with access on the target only allowed to one specific IP. Even better, the script could be designed to run repeatedly to different targets, giving you multiple backups at remote locations, if required.

In our case, we also use the same script, using rsync to backup files to another local disk on the Webserver. This time, not using days of week, but just a daily backup.

The key info to google for here i.s

  • firewall, port forwarding and limit IP access
  • setup ssh between servers via public .pub keys
  • how to use rsync
  • how to use cron

Why so paranoid? Well, we’ve just had two complete server failures on two different hosts. And this took us two weeks to recover from overall. So, backup like this really is a necessity…

Hope this helps

Thanks for such a completed response!