Skip to main content

Snapshot format

Using the API, Tenants and Versions can be provisioned using custom snapshots. In order to use this functionality, a snapshot has to be uploaded to WPCS using the link provided by the API. A snapshot is a basic TGZ file, or a Gzipped TAR file.

When creating a snapshot, it is important to follow the WPCS format for snapshots. A snapshot consists of three parts: a database export, the WP Content folder and a metadata file.

File structure

The file structure in the .tgz file is as follows:

├─ wp-content
│ ├─ plugins
│ ├─ themes
│ ├─ languages
├─ export
│ ├─ metadata.json
│ ├─ db.sql

The /wp-content/plugins folder of course contains all of the plugins that should be in the to-be-created Version. The same applies to the /wp-content/themes and /wp-content/languages folders.

Then the database export and the metadata.json are in the export folder.

note

Please make sure to name every file and folder exactly like shown.

Metadata file

The metadata.json file contains one important piece of metadata: the main WordPress URL that also exists in the db.sql. That is to say, if you created a database export of a site running under https://my-example.com/, the metadata.json file would contain the following:

{
"version": 1,
"originalDomainName": "my-example.com"
}
note

The originalDomainName value is the domain name without the protocol.

Database dump

The database dump is a simple dump of the database using a tool like mysqldump. We recommend using the WP CLI command wp db export (command documentation) to create the database dump. Make sure to actually call the dump file db.sql!

note

Currently WPCS does not support custom table prefixes for uploaded snapshots, so make sure that the WordPress installation you want to make a snapshot of works with the default 'wp_' table prefixes.

Creating the snapshot

You can then use a tool of your choosing to create the .tgz file. A common way to create the file is to simply use the tar -czf snapshot.tgz ./path/to/the/files command. Different ways do exist, so check to see what the capabilities of the OS are that the WordPress site is running on.