Backup and Restore Extension Data

There are three distinctive ways to work with data in the extension to ensure it is backed up and restored when necessary:

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:

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.

Next in this section:

Working with Custom Backup Storages