/wp-snapshot

Create a usable, static copy of your WordPress website.

Primary LanguagePHPGNU General Public License v2.0GPL-2.0

WP-Snapshot

A WordPress Archiving Tool

Build Status

Create a usable, static copy of your WordPress website for backup/archive or live use.

This plugin for WP-CLI allows back-up snapshots of your WordPress website to be created. These are copies which can actually be served on a webserver straight away --- they are simply flat HTML files and the resources used by those pages. Although not as flexible as taking a backup copy of the PHP files and database of your site it does allow a backup copy of your website to be ready to go instantly, on any hosting solution which can serve static files.

The interface is currently all command line based using the brilliant WP-CLI. For recurring backup usage cron is your friend.

To get started:

# Copy the config in to place and edit...
cp config-sample.php config.php
vim config.php

# Show all the URLs which will be saved
wp --require=/path/to/snap.php snap list

# Start archiving!
wp --require=/path/to/snap.php snap shot

The main options of interest are COPY_SRC and REWRITE_LINKS:

COPY_SRC will capture the relevant source files for each page to be displayed correctly. That is all relevant images, CSS and JS files which are hosted on the same hostname as the WordPress installation uses. This effectively runs a capturing regex over the source HTML looking for src attributes with the correct hostname, so it isn't strictly limited to particular types of files.

REWRITE_LINKS can be used to rewrite all references from the WordPress installation hostname to another hostname. For example, my-site.com/blog/... links become backup.my-site.com/blog/... to host a recent backup which is browsable with working links.

Known Issues

Pagination pages are not currently handled correctly.