Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating php application for my client and now thinking what would be the best way to do backups, automatically if possible? I don't have much experience in this area and in case something goes wrong, or if I need to migrate, I would like to have fast way of getting it all back online. I understand "something goes wrong" is a very wide term, but lets say that someone hacks my site and wipes out database and all the files. My app. is written in php/mysql and I got access to cpanel (hosted with if that makes any difference :). I used Joomla and it has JoomlaPack that does complete backup almost automatically and in case site fails, its easy to revert, or migrate if necessary. Is there anything like that for my configuration that would make reverting/migration, easy?


migration rejected from Feb 23 at 20:54

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by HopelessN00b, Jenny D, MadHatter, ptman, Katherine Villyard Feb 23 at 20:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

Your code shouldn't be changing that much so backups of that can be taken care of by the web host (hopefully). They should be on a server that does nightly incremental backups.

For offsite database backups you can go with a service that stores files externally. Alternatively, in the wee hours of the morning, you can gzip your data and use scp to automatically transfer it securely.

Others are fond of cloud storage for backup.

The best way to backup critical data is to have your data backed up and stored in multiple locations.


+1: Both file and DB backups should be performed on a nightly basis by the hosting provider. Since you're new to the game, if there's an extra fee to activate said backups, it's worth your sanity and peace of mind (and time!) to simply pay and be done with it. – Chris Tonkinson Jun 2 '10 at 23:19
@Chris, Imho and professional opinion you shouldn't trust anyone with your data. For example even Microsoft sometimes screws up user data: . Even though they got user's data back, that isn't the point. You should run the backups your self. – Nathan Adams Jun 3 '10 at 0:33
Give a look at It can do mysql and files backup at once, full or incremental and many other things. – Pier Jun 3 '10 at 13:01
Whether you do backups yourself or let your provider make them, the most important thing is to TEST them. Don't trust them if you haven't succesfully recovered from a backup. Act as if your server was hacked and write down the steps you need to take to get your server up again. That was you don't need to figure this out in a stressful situation. – Martijn Heemels Jul 23 '10 at 13:03

For MySQL, I find automysqlbackup an excellent choice. In effect, it keeps daily DB backups for 7 days (configurable), monthly backups for 12 months (configurable), and also makes yearly backups. All of that gives you a history of database changes, so that even if you find something is wrong over a week after that 'wrong' happened - you are still protected! It produces compressed dumps, so to restore you would need a single command piping decompressed data to mysqlimport.

However, it only does local backups (dumps). You will have to configure another tool to push those backups out of your server, not to keep all eggs in one basket.

For PHP files, I would use a distributed software version control system. My personal current favorite is git, but other choices (like mercurial and darcs) are also available. Besides acting as an actual backup with history, it streamlines development process. It is easy to revert to any recorded state.

One could also use rsync for efficient automatic backups with history.

As a universal solution (albeit a heavy one for a simple project - more fit for a whole server) I would use specialized backup tools. I cannot yet recommend a specific one, as I haven't yet run enough comparisons, but I would start with rsync-based dirvish. Other tool names are BackupPC, backupninja, backup manager, rdiff-backup, bacula, backup2l, ...


1 ) version control system for the database. Use tags for releases so you can pinpoint a release for your code base.. put all source code and config files in the VCS

2) mysqldump the client database on a nightly basis and sftp it somewhere.


Not the answer you're looking for? Browse other questions tagged or ask your own question.