Browse Source

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.
stable
Craig Oates 2 years ago
parent
commit
736d12074f
  1. 33
      src/snapshot.lisp

33
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."))
Loading…
Cancel
Save