Create a usable, static copy of your WordPress website.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
tests
.gitignore
.travis.yml
LICENSE
README.mdown
config-sample.php
phpunit.xml
snap.php

README.mdown

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.