mirror of
https://github.com/Sea-Haven-Industries/forgejo.git
synced 2026-09-30 06:33:11 +00:00
fix(terraform): restore forgejo.db from the dump tarball
Boot restore was copying data/ and repos/ and leaving the sqlite file at the archive root, so a volume restore started Forgejo with no database.
This commit is contained in:
parent
530bd7210e
commit
907608c2f6
1 changed files with 21 additions and 2 deletions
|
|
@ -114,11 +114,30 @@ if [ ! -f /var/lib/forgejo/data/forgejo.db ]; then
|
||||||
RESTORE_DIR="$(mktemp -d)"
|
RESTORE_DIR="$(mktemp -d)"
|
||||||
aws s3 cp "s3://${BACKUP_BUCKET}/${S3_PREFIX}/${LATEST}/${FILE}" "$RESTORE_DIR/dump.tar.gz" --region "${AWS_REGION}"
|
aws s3 cp "s3://${BACKUP_BUCKET}/${S3_PREFIX}/${LATEST}/${FILE}" "$RESTORE_DIR/dump.tar.gz" --region "${AWS_REGION}"
|
||||||
tar xzf "$RESTORE_DIR/dump.tar.gz" -C "$RESTORE_DIR"
|
tar xzf "$RESTORE_DIR/dump.tar.gz" -C "$RESTORE_DIR"
|
||||||
cp -a "$RESTORE_DIR"/data/. /var/lib/forgejo/data/
|
mkdir -p /var/lib/forgejo/data /var/lib/forgejo/custom
|
||||||
|
if [ -d "$RESTORE_DIR/data" ]; then
|
||||||
|
cp -a "$RESTORE_DIR"/data/. /var/lib/forgejo/data/
|
||||||
|
fi
|
||||||
|
rm -rf /var/lib/forgejo/data/repositories
|
||||||
mkdir -p /var/lib/forgejo/data/repositories
|
mkdir -p /var/lib/forgejo/data/repositories
|
||||||
cp -a "$RESTORE_DIR"/repos/. /var/lib/forgejo/data/repositories/
|
if [ -d "$RESTORE_DIR/repos" ]; then
|
||||||
|
cp -a "$RESTORE_DIR"/repos/. /var/lib/forgejo/data/repositories/
|
||||||
|
fi
|
||||||
|
# Dump sqlite lives at the archive root, not under data/. Copy it last.
|
||||||
|
cp "$RESTORE_DIR/gitea-db.sqlite3" /var/lib/forgejo/data/forgejo.db
|
||||||
|
if [ -d "$RESTORE_DIR/lfs" ]; then
|
||||||
|
mkdir -p /var/lib/forgejo/data/lfs
|
||||||
|
cp -a "$RESTORE_DIR"/lfs/. /var/lib/forgejo/data/lfs/
|
||||||
|
fi
|
||||||
|
if [ -d "$RESTORE_DIR/custom" ]; then
|
||||||
|
cp -a "$RESTORE_DIR"/custom/. /var/lib/forgejo/custom/
|
||||||
|
fi
|
||||||
chown -R forgejo:forgejo /var/lib/forgejo
|
chown -R forgejo:forgejo /var/lib/forgejo
|
||||||
rm -rf "$RESTORE_DIR"
|
rm -rf "$RESTORE_DIR"
|
||||||
|
if [ ! -s /var/lib/forgejo/data/forgejo.db ]; then
|
||||||
|
echo "Restore did not produce /var/lib/forgejo/data/forgejo.db" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "No backup found in S3 - starting fresh"
|
echo "No backup found in S3 - starting fresh"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue