github.com/greenplum-db/gpbackup@v0.0.0-20240517212602-89daab1885b3/ci/scripts/generate_backup_artifact.bash (about) 1 #!/usr/bin/env bash 2 3 set -ex 4 source env.sh 5 6 mkdir /tmp/backup_artifact # parent dir for all backups 7 8 echo "##### Loading sqldump into DB #####" 9 psql -d postgres -f /home/gpadmin/sqldump/dump.sql >/dev/null 10 11 echo "##### Running pg_dump on regression DB #####" 12 pg_dump regression -f /tmp/regression_dump.sql --schema-only 13 pushd /tmp 14 xz -z regression_dump.sql 15 popd 16 17 # Although the current restore/diff testing only uses the regression 18 # database, we may in the future choose to diff other databases created 19 # in the "src/test/regress" directory of GPDB. 20 # 21 # Because the test suite of src/test/regress includes a database 22 # with a special char ("funny copy""db'with\\quotes"), 23 # iterating through the databases is the easiest way to reference 24 # a list of DBs, using an index rather than db name. 25 # For the regression database, that number is 17, as of March 2019, 26 # and that's the index number expected by the sibling "gprestore" script 27 28 REGRESSION_DB_INDEX=17 29 30 # iterate through all the databases to issue a warning the index changes 31 psql -t postgres -c "SELECT datname FROM pg_database WHERE datistemplate = false;" > /tmp/db_names 32 33 while read -r dbname ; do 34 # skip all but regression 35 [[ "regression" != "${dbname}" ]] && continue 36 37 db_index=${REGRESSION_DB_INDEX} 38 dir="/tmp/backup_artifact/${db_index}" 39 mkdir "${dir}" 40 41 echo "##### Backing up database: ${dbname} #####" 42 gpbackup --dbname "${dbname}" --backup-dir "${dir}" --metadata-only 43 done < /tmp/db_names 44 45 # create tarball of all backups by backing up parent dir 46 pushd /tmp 47 tar -czvf backup_artifact.tar.gz backup_artifact 48 popd