feature/DO-1037/add_scripts_for_postgres (!7)

Reviewed-on: https://git.avroid.tech/DevOps/avroid_scripts/pulls/7
This commit is contained in:
Rustam Tagaev
2024-10-16 16:08:07 +03:00
parent 4e8e15be16
commit 5fa1fe7b84
3 changed files with 36 additions and 8 deletions

View File

@@ -3,6 +3,7 @@
DATE=$(date +%F)
DIRBACKUP="/data/backups"
DBUSER="postgres"
TEST_BACKUP_SERVER="h-license-manager-backup-server.avroid.cloud"
get_leader() {
curl -s 127.0.0.1:8008 | jq -j ".role"
@@ -28,12 +29,18 @@ createBackup() {
bzip2 -9 "${DIRBACKUP}/${db}-${DATE}".sql
copyBackupToTestServer "${DIRBACKUP}/${db}-${DATE}".sql.bz2 ${TEST_BACKUP_SERVER}
echo "END database bzip2: ${db}"
done
pg_dumpall -p 15432 -U postgres --roles-only > "${DIRBACKUP}/roles-${DATE}".sql
copyBackupToTestServer "${DIRBACKUP}/roles-${DATE}".sql ${TEST_BACKUP_SERVER}
}
copyBackupToTestServer() {
rsync $1 $2::backup || true
}
[[ $(ls -A ${DIRBACKUP}) ]] 2>/dev/null && echo "dir ${DIRBACKUP} not empty" && exit 123