What is the purpose of wget backup-converted?

The --backup-converted option in wget is a specialized command-line flag used during website mirroring to preserve original file extensions before they are altered for local viewing. When downloading a website for offline use, wget often converts links (such as changing a dynamic .php or .aspx URL to a local .html file) so the pages can be navigated locally. Enabling this option instructs wget to save a copy of the original file with a .orig suffix before making these permanent formatting adjustments, ensuring that the authentic structure and filenames of the remote server are not lost.

To understand why --backup-converted is valuable, it helps to look at how wget handles website mirroring. Typically, a user will run a command to download a site for offline browsing using the --convert-links (or -k) option.

While link conversion is essential for offline browsing, it permanently alters the source code of the downloaded files.

How the Backup Option Works

When you append --backup-converted (or the short form -K) to your wget command, the utility adds a safety net to the rewriting process.

  1. wget downloads the original file from the server (e.g., index.php).
  2. Before it modifies the links inside index.php to make them local-friendly, it creates an exact duplicate of the original file.
  3. It renames this duplicate by appending .orig to the extension (e.g., index.php.orig).
  4. wget then proceeds to convert the links in the primary file as requested.

Common Use Cases

This option is particularly useful for developers, system administrators, and digital archivists who need to achieve two conflicting goals at once: viewing a site offline while still maintaining a perfect record of the original server-side code structure.

1. Verification and Auditing

If a converted local page doesn’t render correctly, you can compare the modified file against the .orig file to determine if wget’s link conversion caused the layout break or if the issue existed on the live site.

2. Redeployment and Migration

If you are using wget to scrape a site with the intent of hosting it elsewhere or analyzing the original file structure, having the unaltered .orig files ensures you don’t accidentally lose the original asset paths and file extensions to wget’s automated rewriting logic.