Working restic restore from snapshot id on boot.

This commit is contained in:
2026-04-23 19:01:12 -07:00
parent f3b9bfee9a
commit ce5d3f0cc6
6 changed files with 70 additions and 6 deletions

View File

@@ -1304,6 +1304,7 @@ chmod -R 777 /opt/keys")))
(get-most-recent-deployment-status db (session-user-id) instance-id)))))))
(when (not (or (eq? status 'queued) (eq? status 'in-progress)))
(let* ((instance-id (alist-ref "id" (current-params) equal?))
(restic-snapshot-id (alist-ref 'restic-snapshot-id (current-params)))
(results
(with-db/transaction
(lambda (db)
@@ -1372,7 +1373,8 @@ chmod -R 777 /opt/keys")))
("BACKBLAZE_KEY_ID" . ,(alist-ref 'backblaze-key-id service-config))
("BACKBLAZE_APPLICATION_KEY" . ,(alist-ref 'backblaze-application-key service-config))
("BACKBLAZE_BUCKET_URL" . ,(alist-ref 'backblaze-bucket-url service-config))
("RESTIC_PASSWORD" . ,restic-password)))))
("RESTIC_PASSWORD" . ,restic-password)
,@(if (and restic-snapshot-id (not (string=? restic-snapshot-id ""))) `(("RESTIC_SNAPSHOT_ID" . ,restic-snapshot-id)) '())))))
(with-output-to-file (string-append dir "/config/production.tfvars")
(lambda ()
(map (lambda (e)
@@ -1526,7 +1528,8 @@ chmod -R 777 /opt/keys")))
,(alist-ref 'instance-id instance)))
"Modify Setup"))
(li "Upgrade Now (pending automatic upgrades scheduled for: )")
(li "Manage Backups")
(li (a (@ (href "/backups/" ,(alist-ref 'instance-id instance)))
"Manage Backups"))
(li (a (@ (href "/destroy/" ,(alist-ref 'instance-id instance)))
"Destroy - deletes data and configuration (confirmation required)"))
(li (a (@ (href "/reset/" ,(alist-ref 'instance-id instance)))
@@ -1744,6 +1747,27 @@ chmod -R 777 /opt/keys")))
,output)))
)))))
(get/widgets
("/backups/:id")
(let* ((instance-id (alist-ref "id" (current-params) equal?))
;; (res (with-db/transaction
;; (lambda (db)
;; `((status . ,(get-most-recent-deployment-status db (session-user-id) instance-id))
;; (progress . ,(get-most-recent-deployment-progress db (session-user-id) instance-id))))))
)
`(App
(Main-Container
(VStack
(h1 "Backups")
(a (@ (href "/")) "Create Snapshot") ;; TODO
(table
(thead
(tr (th "Time") (th "Size") (th "Tag") (th "*")))
(tbody
(tr (td "2026-04-22 22:24:41") (td "139.742 MiB") (td "") (td (a (@ (href "/")) "Restore")))
(tr (td "2026-04-21 12:01:03") (td "139.742 MiB") (td "before upgrade") (td (a (@ (href "/")) "Restore")))
(tr (td "2026-04-21 22:24:41") (td "129.742 MiB") (td "") (td (a (@ (href "/")) "Restore"))))))))))
(schematra-install)
))