Snapshots
Manage state of your website with snapshotsSnapshot refers to a copy of the state of a website at a particular point in time. Snapshots can be likened to a "photograph", they capture the exact state of a website, both in terms of data and configuration, at a specific moment.
See also the user guide:
Snapshot management
Backup of the environment at a new level
Snapshots definition
A snapshot is essentially a backup, a reference to the precise state of your website, representing environment components like the git commit, the database, and the media library.
Environment components
- Codebase – Instead of saving the entire code, SiteBox uses the git commit reference for the codebase. This approach ensures a reference to the version of the code at the time of the snapshot without redundantly storing the actual files.
- Database – The website's database is captured in its entirety as an SQL dump. This blueprint can be loaded in both local or online environments, ensuring seamless transfer and restoration of database content.
- Media Library – For media assets, the snapshot secures a comprehensive copy of the uploads directory, safeguarding all media files like images, videos, documents, and more.
Snapshot types
-
Manually Triggered Snapshots – Snapshots initiated through the SiteBox Dashboard by an individual with the necessary permissions. This approach is especially useful before implementing major changes, core or plugins updates.
-
Imported Snapshots – Snapshots that have been imported from dieferent environments or composed manually and subsequently imported into the SiteBox Dashboard.
-
Auto Backups – Snapshots created automatically as part of a scheduled auto- backup activity.
Benefits of using Snapshots
- Data Management – Snapshots facilitate efficient data transmission between various environments, including local and online platforms. This capability proves invaluable for developers and teams seeking consistent data across dierent setups.
- Error Reversion – In instances where updates introduce unexpected issues, snapshots offer a mechanism to revert to a prior, stable state, minimising potential downtime and disruptions.
- Recovery – In scenarios of inadvertent data deletions or undesirable modications, snapshots act as a recovery mechanism, enabling restoration to a previous state of the website.
- Migration – Snapshots streamline the process of migration from and to other hosting providers, ensuring migration with all essential data intact.
Structure of a Snapshot
Each snapshot is wrapped in a single directory. While users can choose any name for this directory, we strongly
recommend either snapshot
, backup
, or root
. For the purposes of this explanation, we'll refer to it as the "root
directory".
This root directory must be packaged into a ZIP archive. Crucially, the ZIP package should only contain this one directory. Inside the root directory, there might be one or more dynamic environment components: Git Commit Reference, Database, and Media Library.
Database
The database component is provided as a MySQL dump le, which can be exported from MySQL management tools like PhpMyAdmin, MySQL Workbench, or TablePlus. Dump files should follow the rules listed below:
- The database dump MUST be named
dump.sql
. - The database dump MUST reside in the root directory.
- The database dump MUST NOT be encrypted nor zipped.
- The database dump MUST NOT contain the
USE
orCREATE_TABLE
commands. - The database dump SHOULD utilise the
wp_
prefix. While custom prefixing is applied dynamically, it's essential to retain thewp_
prefix during transit. - Until the release of SiteBox Dashboard v3, the database dump MUST reflect the domain of the target environment (search and replace operations may be necessary).
When database dump is present in the snapshot, restoring it will cause environment database to be overridden by a snapshot.
Media library
The Media Library is packaged as the uploads directory located within the root directory of the snapshot. This mirrors
the structure of the uploads
directory generated by WordPress.
Although the Snapshot Management API won't flag errors in such cases, the uploads directory MUST NOT contain executable or cache files.
When media library directory is present in the snapshot, restoring it will cause all environment media to be overridden by a snapshot.
Example structure
snapshot.zip
└── snapshot/
├── dump.sql
└── uploads/
├── 2023/
├── 2022/
└── ...