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 justhost.com 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 stackoverflow.com 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:
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.
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
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.