Monday, April 2, 2012

Back up your web site.

We have no trouble about backing up our personal computers. What do we do about what we have on-line? I found a fairly easy solution for one site called Guess what it is?  That good old wget command. You could download a site with:

$ wget -c -r

The command will recursively get all of the website it can and stay on top of getting the site till it is done. So then (if your computer supports long file names), you would have a directory called Cool.

You can also go to and have them back up your site. This is great for any site you do not want to lose.

Then I thought about it and wanted to go one step further. That is directly put the files on another local server so I could access them at will. Also did not want to interfere with the existing web pages. So we need an Apache web server that supports virtual hosts. On that server where you have administrative rights. You want to set up your web directory such as:

$ cd /var/www
$ sudo mkdir -p

Then let’s get the files.

$ cd
$ sudo wget -c -r

Now we need to let the server know about the new site. We need to come up with a site name that is not either used on the web or one you can use with a viable dns address. Your network will probably use the net address first and not find your local site, use an unused url and put it in your local dns with the local servers ipaddress. Let’s substitute a new name such as We will need to make a file with that name on the apache server in the sites-available directory in the Apache2 file structure. i.e. should be the ipaddress of the web site of your web server instead.

$ sudo nano /etc/apache2/sites-available/

DocumentRoot /var/www/

Then you need to make a link to the that file in the sites enabled directory.

$ cd /etc/apache2/sites-enabled/
$ ln -s ../sites-available/ .

Then you need to restart the server to let it have the updates and the details of the new site.

$ sudo service apache2 restart

You should be able to reach your local site now if the local dns has been updated for the new site. I did have to disable "use proxy" in my Firefox to see the site.  Any time you need to update the site, just go back to the same directory and run the wget command again. Clear your web browser cache if you still have a problem.

No comments:

Post a Comment