From 736d12074faddd82cf0f405be7c501aa9d68965a Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sun, 23 Oct 2022 18:17:24 +0100 Subject: [PATCH] add snapshot.lisp, implement take-snapshot and stub-out restore. I will add to this as I add more snapshot features into the main website code (I.E. HTML templates and routes in web.lisp). At the moment, this package is a little island right now and doesn't integrate into the rest of the website at all. --- src/snapshot.lisp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/snapshot.lisp diff --git a/src/snapshot.lisp b/src/snapshot.lisp new file mode 100644 index 0000000..fb71fc3 --- /dev/null +++ b/src/snapshot.lisp @@ -0,0 +1,33 @@ +(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.")) + +