From 4bf6f61131af5a3b7847e5e0491eb218120faba2 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 23 Nov 2017 18:42:47 +0400 Subject: External backup function --- lib.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib.php') diff --git a/lib.php b/lib.php index ab20526..c423e9b 100644 --- a/lib.php +++ b/lib.php @@ -108,6 +108,32 @@ function local_webhooks_update_record($data, $insert = true) { return boolval($result); } +/** + * Make a backup copy of all the services. + * + * @return string + */ +function local_webhooks_create_backup() { + $listservices = local_webhooks_get_list_records(); + $listservices = local_webhooks_archiving_data($listservices); + return $listservices; +} + +/** + * Restore the data from the backup. + * + * @param string $data + */ +function local_webhooks_restore_backup($listservices = "") { + $listservices = local_webhooks_unarchive_data($listservices); + + local_webhooks_remove_list_records(); + + foreach ($listservices as $servicerecord) { + local_webhooks_update_record($servicerecord, true); + } +} + /** * Compress an array into a string. * -- cgit v1.2.3