Skip to content

Commit

Permalink
update PG logical backup
Browse files Browse the repository at this point in the history
  • Loading branch information
drivebyer committed Mar 11, 2024
1 parent e70fa7a commit 5da4970
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arm64/images/logical-backup/actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ action=${1:-"dump"}
if [ "$action" = "delete" ]; then
echo "Delete backup..."
/bin/bash /delete.sh
elif [ "$action" = "restore" ]; then
echo "Restore backup..."
/bin/bash /restore.sh
else
echo "Dump backup to remote..."
/bin/bash /dump.sh
Expand Down
13 changes: 13 additions & 0 deletions arm64/images/logical-backup/restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -xe

echo "Downloading backup from S3..."
rclone config create s3 s3 endpoint ${S3_ENDPOINT} access_key_id ${S3_ACCESS_KEY_ID} secret_access_key ${S3_SECRET_ACCESS_KEY}
rclone copy s3:${BAK_FILE_PATH} /
gunzip /$(basename $BAK_FILE_PATH)
echo "Restore backup to database..."
export PGPASSWORD=$PG_PASS
psql -h $PG_HOST -p $PG_PORT -U $PG_USER < /$(basename $BAK_FILE_PATH .gz)

echo "Restore completed!"

0 comments on commit 5da4970

Please sign in to comment.