Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Is there any way to backup a whole website including files and database automatically on LAMP?

phpMyAdmin is avaliable.

I'd like to save zipped files and database sql in the folder above www directory so that no one can access it online.

share|improve this question
up vote 2 down vote accepted

It's pretty easy to write a shell script to do that, and call it from cron (if you have access to cron). If you don't have access to cron because of your hosting service, you can make a secret php file that you call from some other computer that does have cron (I use a Linux box at home to do things like that).

Keep in mind that a backup isn't really a backup until

  • It's in multiple locations, not just on the same computer
  • You've proven it works by restoring it (either to the real site or a test site)

I backup a wordpress site by having a shell script that consists of

mysqldump --opt --user=wordpress wordpress > /backup_1/wordpress.db.transfer
tar cvfz /backup_1/wordpress.tar.gz /www/wordpress

But then I have another backup process that copies /backup_1 across the network to another remote machine.

share|improve this answer
Thanks Paul. Q1: What is Linux box? Q2: what is the file extension of shell script? – shin Aug 15 '10 at 12:44
A1: Linux is the "L" in "LAMP". A "Linux box" is a computer on which you're running Linux. A2: Linux doesn't care about file extensions. – Paul Tomblin Aug 15 '10 at 12:49
+1 for your comments about what is needed for it to truly be a backup. – Slartibartfast Aug 16 '10 at 1:21

rsnapshot is a great tool for making backups of all your files/folders:

Most Linux distributions have a package for it already. It's very easy to setup - check out /etc/rsnapshot.conf which has lots of comments.

For MySQL though, you'll need to take a separate dump of your DB to avoid copying inconsistent files. AutoMySQLBackup has served me well in the past:

It too is easy to setup. Both of these tools should be run from cron.

Hope this helps.

share|improve this answer
+1 This is what I would do. – churnd Aug 16 '10 at 12:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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