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.
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 Wget | Standard Wget Pitfall | How `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 Errors | Default Wget/1.x headers are blocked by Cloudflare and modern web hosts. | Includes a modern desktop browser User-Agent header by default. |
| CDN & Font Assets | Stylesheets and fonts on subdomains (e.g. cdn.site.com) are omitted. | Easily span external domains with -s and -D domain1,domain2. |
| Local Browsing | Downloaded pages link to remote servers or lack .html file extensions. | Applies --convert-links and --adjust-extension automatically. |
| Interrupted Crawls | Stopping 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.comCLI Flag Reference
Full specifications of supported options and behaviors.
| Flag | Argument | Default | Description |
|---|---|---|---|
-h, --help | None | - | Show complete usage summary and exit. |
-v, --version | None | - | Show current mirror version. |
-o, --output-dir | DIR | Current Dir | Directory where files are saved (maps to wget -P). |
-w, --wait | SECS | 1 | Base wait time between requests. Randomizer varies it by ±50%. |
-u, --user-agent | STRING | Chrome Desktop | Custom User-Agent string sent with all HTTP headers. |
-s, --span-hosts | None | Off | Allow downloading page prerequisites from external domains/CDNs. |
-D, --domains | DOMAINS | None | Comma-delimited whitelist of domains to crawl when spanning hosts. |
--no-robots | None | Off | Bypasses robots.txt restrictions via -e robots=off. |
--debug | None | Off | Prints 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 -- --spiderFrequently 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.