How to Mirror & Archive Websites for Offline Backups (wget, HTTrack & Web Tools)
A practical Linux and DevOps guide to creating complete offline website snapshots—covering production wget mirroring flags, rate limiting, handling modern frontend assets, and automating recurring snapshots with cron.
Why DevOps Teams Maintain Offline Website Archives
Whether you are decommissioning a legacy marketing site, preserving documentation before a CMS migration, or creating a compliance snapshot of static HTML, CSS, and JavaScript assets, relying solely on database dumps is rarely enough. A self-contained offline mirror captures the exact rendered markup, stylesheets, fonts, and media served to visitors so the archive can be opened locally or re-hosted on static edge storage without running the original backend stack.
Depending on the target site's architecture—plain static HTML versus JavaScript-heavy single-page apps—you can choose between command-line crawlers like GNU wget, desktop mirroring tools like HTTrack, or browser-based extractors.
1. Full-Site Mirroring with GNU wget
On Linux and macOS servers, GNU wget is the standard command-line utility for recursive HTTP archiving. The following production command downloads an entire site, pulls all required CSS/JS/image assets, and rewrites links so the mirror works cleanly offline:
wget \
--mirror \
--convert-links \
--adjust-extension \
--page-requisites \
--no-parent \
--wait=1 \
--random-wait \
--limit-rate=500k \
--directory-prefix=./site-archive \
https://example.org/
Flag-by-Flag Breakdown
| Flag | Short Form | Purpose in Archiving |
|---|---|---|
--mirror |
-m |
Enables recursion, timestamping (-N), infinite recursion depth, and preserves directory listings. |
--convert-links |
-k |
Rewrites absolute URLs inside downloaded HTML and CSS to relative local paths for offline browsing. |
--adjust-extension |
-E |
Appends .html to extensionless routes (e.g., /about becomes about.html) so local file viewers render them properly. |
--page-requisites |
-p |
Fetches all supporting assets needed to display each page: stylesheets, scripts, inline images, and webfonts. |
--no-parent |
-np |
Prevents the crawler from ascending above the target path when archiving a single subdirectory like /docs/. |
--wait=1 --random-wait |
-w 1 |
Pauses 0.5–1.5 seconds between requests to avoid triggering WAF rate limits or overloading the origin server. |
2. Avoiding WAF Blocks, Infinite Loops & Query-String Traps
Unconstrained recursive crawls frequently stall on calendar widgets, faceted search URLs, or dynamic pagination. Before mirroring a large site, add explicit reject patterns and bandwidth ceilings:
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent \
--reject-regex '(\?sort=|\?filter=|/wp-admin/|/search)' \
--tries=3 --timeout=15 \
--user-agent="Mozilla/5.0 (compatible; ArchiveBot/1.0)" \
--output-file=archive-crawl.log \
https://example.org/docs/
- Respect server capacity: Pair
--limit-rate=500kwith--wait=1so origin CPU and bandwidth stay unaffected during business hours. - Capture crawl telemetry: Writing output to
archive-crawl.loglets you inspect HTTP 404 or 429 responses afterward using standard Linux bash log-parsing recipes. - Spanning asset CDNs: If images or stylesheets live on a separate CDN subdomain (such as
cdn.example.org), add--span-hosts --domains=example.org,cdn.example.orgso assets are included without crawling the entire web.
3. CLI Crawlers vs. Browser-Based Website Downloaders
While GNU wget excels at server-rendered HTML and automated Linux pipelines, it does not execute client-side JavaScript. Modern sites built with React, Vue, or lazy-loaded asset bundles often require either a desktop crawler or a browser-based extractor.
When you need a fast offline snapshot of a site's HTML, CSS, JavaScript, and media files without installing CLI packages or tuning recursive flags, WebExtractor's online website downloader provides a zero-setup browser workflow that packages page assets into a clean downloadable archive. For multi-gigabyte deep crawls or scheduled headless backups, CLI utilities remain the right fit.
| Tool | Environment | Best Use Case | Limitations |
|---|---|---|---|
| GNU wget | Linux / macOS CLI | Automated cron backups, static docs, server-rendered sites | No JavaScript execution; requires manual flag tuning |
| HTTrack | Desktop / CLI | Interactive full-site mirrors with resume and filter GUI | Requires local installation; struggles with heavy SPAs |
| WebExtractor | Web Browser (Zero Install) | Fast extraction of HTML, CSS, JS, and media into an offline ZIP | Designed for on-demand snapshots rather than daemon cron jobs |
| Internet Archive | Public Web Service | Public historical citations and timestamped third-party proof | Public only; cannot archive private staging environments |
4. Automating Weekly Offline Archives with Cron
For production documentation portals or compliance snapshots, wrap your wget mirror in a timestamped shell script that compresses the output into a portable .tar.gz bundle and generates a SHA-256 verification checksum:
#!/usr/bin/env bash
set -euo pipefail
STAMP="$(date +%Y-%m-%d)"
DEST="/var/backups/site-archives/${STAMP}"
mkdir -p "${DEST}"
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent \
--wait=1 --limit-rate=500k --quiet \
--directory-prefix="${DEST}" \
https://example.org/
tar -czf "/var/backups/site-archives/site-${STAMP}.tar.gz" -C "${DEST}" .
sha256sum "/var/backups/site-archives/site-${STAMP}.tar.gz" > "/var/backups/site-archives/site-${STAMP}.sha256"
rm -rf "${DEST}"
Make the script executable (chmod 750 /usr/local/bin/archive-site.sh—verify octal modes with our chmod calculator) and schedule it every Sunday at 2:00 AM using crontab -e:
0 2 * * 0 /usr/local/bin/archive-site.sh >> /var/log/site-archive.log 2>&1
Need to customize the schedule? Preview exact run timestamps with the crontab visualizer, copy ready-made patterns from our Linux crontab examples, or check the cron troubleshooting guide if your backup script does not fire.
5. Testing & Serving Your Offline Mirror Locally
Opening archived HTML files directly via file:// URLs can trigger browser CORS errors or break root-relative asset paths. Always validate your offline mirror over a local HTTP loopback server:
cd ./site-archive/example.org
python3 -m http.server 8080 --bind 127.0.0.1
Open http://127.0.0.1:8080 in a browser with DevTools Network tab open and verify that stylesheets, fonts, and images return HTTP 200 locally with zero unexpected outbound requests to the live origin.
Frequently Asked Questions
Does wget --mirror download images hosted on external CDNs?
Not by default. wget restricts downloads to the starting hostname unless you add --span-hosts (-H) paired with --domains=example.org,cdn.example.org. Always specify --domains when using -H so the crawler does not follow outbound links onto unrelated websites.
Why do some pages look unstyled after downloading with wget?
Missing styles usually happen when --page-requisites (-p) or --convert-links (-k) is omitted, when CSS files are hosted on a separate CDN domain, or when styles are injected dynamically via JavaScript frameworks after initial page load.
How can I archive a website without installing command-line tools?
If you are working on a locked-down machine or just need a quick static copy of a site's HTML, CSS, and assets, use a browser-based extractor like WebExtractor (linked in the comparison section above) to fetch and download a clean archive directly from your browser.
Is it safe to mirror a live production website?
Yes, provided you own the site or have permission and throttle your crawler. Always use --wait=1, --random-wait, and --limit-rate so archival traffic stays well below normal user load and avoids triggering DDoS or WAF blocks.