How To Mirror A Website With wget

A common requirement for backups or just to have a local copy of a website is to mirror it. This is easily done with the wget tool.

wget is a command line tool for retrieving files over a network. As is common with the older Linux tools it has a huge number of really useful options. For this use case wget comes with a bunch options to access a website and by following all the internal links download the entire site to a local, browsable copy.

The full set of options that we will use are as follows:

wget \
  --mirror \
  --page-requisites \
  --html-extension \
  --convert-links \
  <SITE-ADDRESS>

All you need to do is to replace with the web address of the website (without HTTP/HTTPS) that you use to access the site e.g. www.example.com.

This command will mirror the target website into a directory under the one you are in with the name of the domain name.

This page on https://explainshell.com will explain all the options I used.