How to use wget to mirror an entire site locally or on a web server

| | 1 min read

We get frequent requests to rebuild existing sites using Drupal. When we get such a request it would help to have a copy of the full site on our local server to make it easier for themers and developers to reuse whatever existing components that can be salvaged from the original site. Wget is a powerful tool that can help mirror websites locally or on any web servers.

The command for doing this using wget is really simple.

wget --recursive --no-clobber --page-requisites --html-extension --convert-links
--restrict-file-names=windows --no-parent --background --limit-rate=250k --wait=1 
--domains=www.example.com www.example.com 

Make sure that you change the example.com for the --domains parameter and the final argument to whatever domain/site you wish to mirror. You can also decide to change the limit-rate and wait parameters based on the capability of the servers.

This will create a folder www.example.com in the folder where you run the command. The --background parameter puts the process into the background and the progress of the download can be seen from the wget-log in the same folder.