Merge pull request #18 from jkaninda/develop
feat: add database backup verification
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
|||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
file: "./src/docker/Dockerfile"
|
file: "./src/Dockerfile"
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: |
|
tags: |
|
||||||
"${{env.BUILDKIT_IMAGE}}:v0.2"
|
"${{env.BUILDKIT_IMAGE}}:v0.2"
|
||||||
|
|||||||
4
build.sh
4
build.sh
@@ -6,6 +6,6 @@ if [ $# -eq 0 ]
|
|||||||
tag=$1
|
tag=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker build -f src/docker/Dockerfile -t jkaninda/pg-bkup:$tag .
|
docker build -f src/Dockerfile -t jkaninda/pg-bkup:$tag .
|
||||||
|
|
||||||
docker compose up -d
|
#docker compose up -d
|
||||||
@@ -13,7 +13,6 @@ ARG DEBIAN_FRONTEND=noninteractive
|
|||||||
ENV VERSION="0.2"
|
ENV VERSION="0.2"
|
||||||
|
|
||||||
RUN apt-get update -qq
|
RUN apt-get update -qq
|
||||||
RUN apt-get install build-essential libcurl4-openssl-dev libxml2-dev mime-support -y
|
|
||||||
RUN apt install s3fs postgresql-client postgresql-client-common libpq-dev supervisor cron -y
|
RUN apt install s3fs postgresql-client postgresql-client-common libpq-dev supervisor cron -y
|
||||||
|
|
||||||
# Clear cache
|
# Clear cache
|
||||||
@@ -155,11 +155,15 @@ else
|
|||||||
export PGPASSWORD=${DB_PASSWORD}
|
export PGPASSWORD=${DB_PASSWORD}
|
||||||
## Test database connection
|
## Test database connection
|
||||||
|
|
||||||
|
export BK_FILE_NAME="${DB_NAME}_${TIME}.sql.gz"
|
||||||
## Backup database
|
## Backup database
|
||||||
pg_dump -h ${DB_HOST} -p ${DB_PORT} -U ${DB_USERNAME} -d ${DB_NAME} | gzip > ${STORAGE_PATH}/${DB_NAME}_${TIME}.sql.gz
|
pg_dump -h ${DB_HOST} -p ${DB_PORT} -U ${DB_USERNAME} -d ${DB_NAME} | gzip > ${STORAGE_PATH}/$BK_FILE_NAME
|
||||||
echo "$TIME: ${DB_NAME}_${TIME}.sql.gz" | tee -a "${STORAGE_PATH}/history.txt"
|
if [[ $? -eq 0 ]];then
|
||||||
|
echo $BK_FILE_NAME | tee -a "${STORAGE_PATH}/history.txt"
|
||||||
info "Database has been saved"
|
info "Database has been backed up"
|
||||||
|
else
|
||||||
|
fatal "An error occurred during the backup"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@@ -266,7 +270,7 @@ scheduled_mode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
flags "$@"
|
flags "$@"
|
||||||
# ?
|
|
||||||
if [ $EXECUTION_MODE == 'default' ]
|
if [ $EXECUTION_MODE == 'default' ]
|
||||||
then
|
then
|
||||||
if [ $OPERATION != 'backup' ]
|
if [ $OPERATION != 'backup' ]
|
||||||
|
|||||||
Reference in New Issue
Block a user