Disaster recovery backup

You never know when that hacker is going to strike and erase everything from your site, or if your shared hosting provider will fail to backup your stuff at the wrong time. I like to keep website backups myself once in a while, at least before major updates of my sites.

If you are using wordpress or drupal I believe there are plugins/modules that can do this for you.

If you have a simple 10 page website then you can probably just download those files in your computer using an FTP client such as FileZilla.

If your site is considerably larger than there is of course the Cpanel backup utilities that usually comes with you shared web hosting and it actually lets you click and download the "home directory backup" and each database that exists on your account. You can find all these by clicking "backups" from your Cpanel's main page.

If you have more than one website on your hosting account than you might want to zip and download individual sites. What I usually do in this case is grab the database from within my control panel and use the excellent php-shell of Martin Geisler to zip the folder of the site and then download the zip file (using FTP) in one download which saves lots of download time (compared to downloading individual files from the server).

Here is some simple shell commands that will help get the job done. To zip a directory named "folder" into a file "backup.zip" use the following command

zip -rq backup.zip folder

To unzip that folder use

unzip -q backup.zip

to get into the directory named "folder" use

cd folder

To go to the parent directory use

cd ..

To see a list of folders and files in the current directory use

ls

I am just going to mention here that to get a database backup you need to use the "mysqldump" command .
If you want to play a little more with the command line do a search on shell commands or unix commands.

This scripts does not work under all Apache configurations so if it fails to do so you might want to take a look another similar script PhpSh another reason why the script will fail is because the system does not have the zip utility. Perhaps in this case you can try to learn the "tar" or "tar gz" which I am not familiar with.

A word of caution: even though php-shell ask you to provide a userid and password before you start operating it and this makes it secure enough its not a reason to leave it on the server if you are not using it. I usually ftp it on the server before I do any command line work and then erase the file after finishing. As a matter of fact some hosting servers are considering it a very powerful tool and actually pretend not to see it if you try to access it by its name "php-shell" and for this reason I usually end up renaming it to something like "script.php"

Of course there is also the solution of using SSH to access your server using command line environment but SSH does not come by default in most webhosting packages that I know and it is usually activated after the clients request or one has to pay extra for it, theoretically you can apply the same commands since both SSH and php-shell are both emulating the command environment of *NIX systems.

Lastly there is also a free tool that I am aware of PhpMyBackUpPro that you might want to try (there might be others) that I probably does a good job but last time I tried it was a bit of a hassle to configure so I let it rest. According to the website it can actually save databases and folders of your choice and either store them on the server or email them or FTP them to another server which is all you could ask from a backup utility, it can actually be set to do all this automatically on specified intervals.

Category: 

1 Comment

Of course there is also the solution of using SSH to access your server using command line environment but SSH does not come by default in most webhosting packages that I know and it is usually activated after the clients request or one has to pay extra for it, theoretically you can apply the same commands since both SSH and php-shell are both emulating the command environment of *NIX systems.