(in-package #:cl-user) (defpackage #:snapshot (:use #:cl #:utils #:storage #:nera) (:export #:take-snapshot #:restore-from-snapshot)) (in-package #:snapshot) (defun take-snapshot () "Takes a Snapshot of the website's data and stores it in /snapshots. I've not included make a SQL dump of the Meilisearch database here because the user can repopulate that database after they have restored this website. The 'repopulate' feature is built into the website already." (let ((snapshot-directory (format nil "~a_~a/" (utils:slugify (site-settings::site-name-of (nera:get-site-settings))) (utils:create-timestamp-text)))) (storage:ensure-raw-directory-exists (format nil "snapshots/~a" snapshot-directory)) (storage:copy-storage-directory (format nil "snapshots/~a/storage/" snapshot-directory)) (storage:copy-raw-directory "db/" (format nil "snapshots/~a/db/" snapshot-directory)))) (defun restore-from-snapshot (snapshot-name) "Deletes the data in /storage and the DB and replaces it with `SNAPSHOT-NAME'." (format t "RESTORE-FROM-SNAPSHOT NOT IMPLEMENTED."))