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 Blogger.com. Guess what it is? That good old wget command. You
could download a site with:
$ wget -c -r www.whateverthesitenameis.com
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
www.whateverthesitenameis.com. Cool.
You can also go to www.archive.org 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 www.whateverthesitenameis.com/html
Then let’s get the files.
$ cd www.whateverthesitenameis.com/html
$ sudo wget -c -r www.whateverthesitenameis.com
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 www.mysitebackedup.com. 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.
192.168.1.61 should be the ipaddress of the web site of your web server instead.
$ sudo nano /etc/apache2/sites-available/www.mysitebackedup.com
<VirtualHost 192.168.1.61:80>
ServerName www.mysitebackedup.com
ServerAlias www.mysitebackedup.com
ServerAdmin me@there.com
DocumentRoot /var/www/www.whateverthesitenameis.com/html
</VirtualHost>
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/www.mysitebackedup.com .
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