Public archive for the Return to Ritherdon project.
https://www.nicolaellisandritherdon.com
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.6 KiB
39 lines
1.6 KiB
(in-package #:cl-user) |
|
(defpackage #:snapshot |
|
(:use #:cl |
|
#:utils |
|
#:storage |
|
#:nera) |
|
(:export |
|
#:take-snapshot |
|
#:restore-from-snapshot |
|
#:delete-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'." |
|
(storage:remove-raw-directory "storage/") |
|
(storage:remove-raw-directory "db/") |
|
(storage:copy-raw-directory (format nil "snapshots/~a/storage/" snapshot-name) "storage/") |
|
(storage:copy-raw-directory (format nil "snapshots/~a/db/" snapshot-name) "db/")) |
|
|
|
(defun delete-snapshot (snapshot-name) |
|
"Deletes the snapshot in the /snapshots directory with `SNAPSHOT-NAME'." |
|
(storage:remove-raw-directory (format nil "snapshots/~a/" snapshot-name)))
|
|
|