Does anybody know a clean PHP-based solution that can backup remote web sites using FTP?
Must haves:
- Recursive FTP backups
- Possible to run through a cron job
- Easy to configure (easy adding of multiple sites)
- Local storage of backup files is sufficient
Would be nice:
- Backed up sites are stored as zip files
- A nice interface to manage things
- Provides notification when backup has succeeded or failed
- Does incremental backups
- Does MySQL Database backups
I need this to be PHP based because it's going to be used on shared hosting packages that do not allow usage of the standard GNU/Linux tools.
I actually wrote an article w/ included scripts on how I accomplished this using PHP, Bash and some other pieces of open source software to send out the pre-formatted email notifications about the backups.
http://codeuniversity.com/scripts/scr1
My requirements were fairly similar although there is no FTP involved. It's all done locally. Give it a look. Perhaps you may find it useful.
I’m using myRepono, in addition to what you have mentioned, if performs fast and automatic backups and it’s very stable and secure.
I have done something like this in a cron job PHP script before. Not sure if it is the best way, but it certainly works.
You could then exec an sftp to the remote server.
You could do the file folders similarly using exec() and linux zipping.
While your shared hosting may not provide many tools, it must provide at least some, it might be worth asking your host what they provide or recommend for backups. Do you want to back up to a pretty much identical host. (at least in terms of software)
To run rsync successfully it only has to be running on one machine, the other doesn't need to even know that rysnc exists, it also doesn't matter which one of the machines is running it (backup or primary host).
Do you have cli access to the server to install packages or php modules? If you don't then all bets are off as the chances are that your php install won't include any of the necessary packagesn to begin to think about attempting this from php.
I would reccommend a non php solution like rysnc or a bash script of some kind. Although you could wrap the process in a php wrapper to manage it.
I coded this to handle the FTP backups, not sure if it fits your specific needs tho:
Usage:
For MySQL backups, would
SELECT INTO OUTFILE
do it?