There are three distinctive ways to work with data in the extension to
ensure it is backed up and restored when necessary:
- Storing the data in the Plesk Key-Value Storage,
- Storing the data in SQLite databases,
- Using Backup SDK hooks.
Plesk Key-Value Storage
This is the recommended way, it covers most cases. The idea here is to
store and work with the extension data using the following methods:
-
pm_Client::setSetting()
and
pm_Client::getSetting()
for customer and reseller data, -
pm_Domain::setSetting()
and
pm_Domain::getSetting()
for subscription or domain data, and -
pm_Settings:set()
and
pm_Settings::get()
for any kind of data
This way, all the data is stored in the Plesk Key-Value Storage, which
is automatically backed up with the rest of Plesk data. Also, all the
extension data in the Key-Value Storage can be safely and correctly
restored. To sum up, using this approach eliminates the need to take any
additional steps to facilitate the extension data backup and restore.
SQLite Databases
All the data saved by the extension in its local database will be stored
on the file system in the Plesk /var/
directory (use the
pm_Context::getVarDir()
method to obtain the exact location). This directory is automatically
backed up by Plesk whenever a server backup is performed. The extension
data will be restored along with the rest of Plesk data during a full
server restore.
Note: The extension data will not be backed up in case it is only a
subscription or a customer or reseller account that is being backed
up.
Note: The extension data will not be restored in the case of a partial
(select accounts or subscriptions) restore from a full server backup.
To ensure the integrity of your extension data, please keep in mind the
following important information.
Warning: In the course of restoring backed up Plesk data, some of the restored
Plesk object IDs may be changed. If your extension stores such Plesk
object IDs in the database, they may become outdated and incorrect
after the restore.
Using
GUIDs
or names to reference the Plesk objects, when necessary, will help
protect the integrity of your extension data through the backup and
restore processes.
Backup SDK Hooks
In rare cases, when the specifics of certain extension data make it
impossible to use the Key-Value Storage, the mechanism of backup SDK
hooks can be used instead.
Classes
pm_Hook_Backup_Client,
pm_Hook_Backup_Domain
and
pm_Hook_Backup_Server
provide methods backup()
and restore()
. Depending on the nature
of data, one or several of these classes should be used to create
extension classes that inherit and override methods backup()
and
restore()
with relevant instructions on how the corresponding data
is to be backed up and restored.