v1.0.0 — Modernized & Ready

Reliable Website Mirroring, Simplified

A battle-tested wrapper around wget that eliminates broken assets, avoids bot blocks, converts relative links, and fixes the zero-wait randomizer bug out of the box.

curl -sL https://raw.githubusercontent.com/joshuacox/mirror/master/bootstrap | bash
Advertisement

Why Use `mirror` Over Raw `wget`?

wget is powerful, but remembering over 10 flags and navigating obscure edge cases makes mirroring frustrating. Here is how mirror fixes raw wget issues:

Challenge with Raw WgetStandard Wget PitfallHow `mirror` Solves It
Random Wait Delay--random-wait has no effect because --wait defaults to 0.Defaults to --wait=1 so requests safely fluctuate between 0.5s and 1.5s.
Anti-Bot 403 ErrorsDefault Wget/1.x headers are blocked by Cloudflare and modern web hosts.Includes a modern desktop browser User-Agent header by default.
CDN & Font AssetsStylesheets and fonts on subdomains (e.g. cdn.site.com) are omitted.Easily span external domains with -s and -D domain1,domain2.
Local BrowsingDownloaded pages link to remote servers or lack .html file extensions.Applies --convert-links and --adjust-extension automatically.
Interrupted CrawlsStopping a multi-gigabyte crawl requires re-downloading from scratch.Applies --continue and timestamping to resume where it left off.

⚡ Zero Configuration

Pass a single URL and get a fully browsable, offline-ready local mirror without memorizing flags.

🛡️ Polite & Safe

Built-in rate limiting and randomized jitter protect target servers and your IP from bans.

📦 Portable & Lightweight

Pure Bash script with zero runtime bloat. Works anywhere wget and standard POSIX tools run.

Interactive Command Builder

Customize your crawl parameters and generate the exact shell command.

mirror -o ./archives -s -D example.com,cdn.example.com https://docs.example.com

CLI Flag Reference

Full specifications of supported options and behaviors.

FlagArgumentDefaultDescription
-h, --helpNone-Show complete usage summary and exit.
-v, --versionNone-Show current mirror version.
-o, --output-dirDIRCurrent DirDirectory where files are saved (maps to wget -P).
-w, --waitSECS1Base wait time between requests. Randomizer varies it by ±50%.
-u, --user-agentSTRINGChrome DesktopCustom User-Agent string sent with all HTTP headers.
-s, --span-hostsNoneOffAllow downloading page prerequisites from external domains/CDNs.
-D, --domainsDOMAINSNoneComma-delimited whitelist of domains to crawl when spanning hosts.
--no-robotsNoneOffBypasses robots.txt restrictions via -e robots=off.
--debugNoneOffPrints the exact wget invocation before execution.
-- <EXTRA>Pass-through-Passes any additional native wget flags directly.

Common Recipes

Ready-to-use workflows for real-world scraping and archiving.

📚 Offline Documentation Archive

Archive an entire documentation portal into a dedicated folder with polite pacing:

mirror -o ~/docs/redis -w 2 https://redis.io/docs/

🌐 Preserve Sites with Subdomain CDNs

Ensure images, fonts, and scripts stored on asset subdomains are captured:

mirror -s -D site.com,assets.site.com,cdn.site.com https://site.com

⏱️ Bandwidth-Limited Mirroring

Cap download speeds so network traffic isn't saturated during large backups:

mirror https://example.com -- --limit-rate=750k

🔍 Dry-Run Inspection

Verify connectivity and link validity without saving files to disk:

mirror https://example.com -- --spider
Advertisement

Frequently Asked Questions

Does mirror work with Single Page Apps (React/Vue)?

wget retrieves server-rendered HTML, CSS, images, and raw JS bundles. For websites that rely entirely on client-side JavaScript execution to generate DOM nodes, a headless browser tool like Playwright or Puppeteer is recommended.

Can I resume an interrupted mirror session?

Yes! mirror includes --continue and timestamping out of the box. Running the exact same command in the same directory will skip already-completed files and resume where it stopped.

Can I install mirror without root / sudo privileges?

Yes. Run make PREFIX="$HOME/.local" install to install it directly into your user's local bin directory without requiring administrative access.

How do I uninstall mirror?

Run sudo make uninstall (or make PREFIX="$HOME/.local" uninstall for user-local installations) to completely remove the executable.