elmerzole commited on
Commit
7cd875f
·
verified ·
1 Parent(s): ecc7366

Create restore.sh

Browse files
Files changed (1) hide show
  1. restore.sh +24 -0
restore.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ WORKDIR=/tmp/gotify_restore
5
+ mkdir -p $WORKDIR
6
+
7
+ if [ -z "${GITHUB_TOKEN:-}" ]; then
8
+ echo "[restore] ERROR: GITHUB_TOKEN not set"
9
+ exit 1
10
+ fi
11
+
12
+ echo "[restore] Cloning repo..."
13
+ git clone --depth 1 "https://${GITHUB_TOKEN}@${GITHUB_REPO#https://}" $WORKDIR
14
+
15
+ if [ -f "$WORKDIR/$BACKUP_FILE" ]; then
16
+ echo "[restore] Found backup, decrypting..."
17
+ openssl enc -d -aes-256-cbc -pbkdf2 -iter 100000 \
18
+ -in "$WORKDIR/$BACKUP_FILE" \
19
+ -out "$GOTIFY_DATABASE_PATH" \
20
+ -k "$ENCRYPTION_KEY"
21
+ echo "[restore] Restored DB to $GOTIFY_DATABASE_PATH"
22
+ else
23
+ echo "[restore] No backup file in repo, skipping."
24
+ fi