mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-11-28 09:33:54 +02:00
Remove old bash tests.
This commit is contained in:
parent
31c8090216
commit
1874b89d30
2
Makefile
2
Makefile
@ -24,8 +24,6 @@ OBJS = backup.o \
|
||||
|
||||
EXTRA_CLEAN = datapagemap.c datapagemap.h xlogreader.c receivelog.c receivelog.h streamutil.c streamutil.h logging.h
|
||||
|
||||
REGRESS = init option show delete backup restore
|
||||
|
||||
all: checksrcdir datapagemap.h logging.h receivelog.h streamutil.h pg_probackup
|
||||
|
||||
MAKE_GLOBAL="../../src/Makefile.global"
|
||||
|
@ -1,40 +0,0 @@
|
||||
\! bash sql/backup.sh
|
||||
###### BACKUP COMMAND TEST-0001 ######
|
||||
###### full backup mode ######
|
||||
0
|
||||
1
|
||||
3
|
||||
###### BACKUP COMMAND TEST-0002 ######
|
||||
###### page-level backup mode ######
|
||||
0
|
||||
2
|
||||
6
|
||||
###### BACKUP COMMAND TEST-0003 ######
|
||||
###### full backup with smooth checkpoint ######
|
||||
0
|
||||
1
|
||||
3
|
||||
###### BACKUP COMMAND TEST-0005 ######
|
||||
###### switch backup mode from page to full ######
|
||||
page-level backup without validated full backup
|
||||
1
|
||||
0
|
||||
0
|
||||
###### BACKUP COMMAND TEST-0006 ######
|
||||
###### ptrack backup mode ######
|
||||
0
|
||||
0
|
||||
2
|
||||
6
|
||||
###### BACKUP COMMAND TEST-0007 ######
|
||||
###### ptrack multi thread backup mode ######
|
||||
0
|
||||
0
|
||||
2
|
||||
6
|
||||
###### BACKUP COMMAND TEST-0008 ######
|
||||
###### ptrack multi thread backup mode + stream ######
|
||||
0
|
||||
0
|
||||
2
|
||||
6
|
@ -1,13 +0,0 @@
|
||||
\! bash sql/delete.sh
|
||||
###### DELETE COMMAND TEST-0001 ######
|
||||
###### delete full backups ######
|
||||
try to delete the oldest backup
|
||||
2
|
||||
0
|
||||
Number of deleted backups should be 1, is it so?: 0
|
||||
###### DELETE COMMAND TEST-0002 ######
|
||||
###### keep backups which are necessary for recovery ######
|
||||
try to delete before third backup
|
||||
3
|
||||
0
|
||||
Number of deleted backups should be 1, is it so?: 0
|
@ -1,32 +0,0 @@
|
||||
\! bash sql/init.sh
|
||||
###### INIT COMMAND TEST-0001 ######
|
||||
###### success with archive_command ######
|
||||
0
|
||||
results/init/backup/
|
||||
results/init/backup/backups/
|
||||
results/init/backup/pg_probackup.conf
|
||||
results/init/backup/wal/
|
||||
###### INIT COMMAND TEST-0002 ######
|
||||
###### success with archive_command and log_directory ######
|
||||
0
|
||||
results/init/backup/
|
||||
results/init/backup/backups/
|
||||
results/init/backup/pg_probackup.conf
|
||||
results/init/backup/wal/
|
||||
###### INIT COMMAND TEST-0003 ######
|
||||
###### success without archive_command ######
|
||||
0
|
||||
results/init/backup/
|
||||
results/init/backup/backups/
|
||||
results/init/backup/pg_probackup.conf
|
||||
results/init/backup/wal/
|
||||
###### INIT COMMAND TEST-0004 ######
|
||||
###### failure with backup catalog already existed ######
|
||||
ERROR: backup catalog already exist and it's not empty
|
||||
1
|
||||
|
||||
###### INIT COMMAND TEST-0005 ######
|
||||
###### failure with backup catalog should be given as absolute path ######
|
||||
ERROR: -B, --backup-path must be an absolute path
|
||||
1
|
||||
|
@ -1,112 +0,0 @@
|
||||
\! bash sql/option.sh
|
||||
###### COMMAND OPTION TEST-0001 ######
|
||||
###### help option ######
|
||||
pg_probackup manage backup/recovery of PostgreSQL database.
|
||||
|
||||
Usage:
|
||||
pg_probackup [option...] init
|
||||
pg_probackup [option...] backup
|
||||
pg_probackup [option...] restore
|
||||
pg_probackup [option...] show [backup-ID]
|
||||
pg_probackup [option...] validate backup-ID
|
||||
pg_probackup [option...] delete backup-ID
|
||||
pg_probackup [option...] delwal [backup-ID]
|
||||
|
||||
Common Options:
|
||||
-B, --backup-path=PATH location of the backup storage area
|
||||
-D, --pgdata=PATH location of the database storage area
|
||||
|
||||
Backup options:
|
||||
-b, --backup-mode=MODE backup mode (full, page, ptrack)
|
||||
-C, --smooth-checkpoint do smooth checkpoint before backup
|
||||
--stream stream the transaction log and include it in the backup
|
||||
-S, --slot=SLOTNAME replication slot to use
|
||||
--backup-pg-log backup of pg_log directory
|
||||
-j, --threads=NUM number of parallel threads
|
||||
--progress show progress
|
||||
|
||||
Restore options:
|
||||
--time time stamp up to which recovery will proceed
|
||||
--xid transaction ID up to which recovery will proceed
|
||||
--inclusive whether we stop just after the recovery target
|
||||
--timeline recovering into a particular timeline
|
||||
-j, --threads=NUM number of parallel threads
|
||||
--progress show progress
|
||||
|
||||
Delete options:
|
||||
--wal remove unnecessary wal files
|
||||
|
||||
Connection options:
|
||||
-d, --dbname=DBNAME database to connect
|
||||
-h, --host=HOSTNAME database server host or socket directory
|
||||
-p, --port=PORT database server port
|
||||
-U, --username=USERNAME user name to connect as
|
||||
-w, --no-password never prompt for password
|
||||
-W, --password force password prompt
|
||||
|
||||
Generic options:
|
||||
-q, --quiet don't write any messages
|
||||
-v, --verbose verbose mode
|
||||
--help show this help, then exit
|
||||
--version output version information and exit
|
||||
|
||||
Read the website for details. <https://github.com/postgrespro/pg_probackup>
|
||||
Report bugs to <https://github.com/postgrespro/pg_probackup/issues>.
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0002 ######
|
||||
###### version option ######
|
||||
pg_probackup 1.0
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0003 ######
|
||||
###### backup command failure without backup path option ######
|
||||
ERROR: required parameter not specified: BACKUP_PATH (-B, --backup-path)
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0004 ######
|
||||
###### backup command failure without backup mode option ######
|
||||
ERROR: Required parameter not specified: BACKUP_MODE (-b, --backup-mode)
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0005 ######
|
||||
###### backup command failure with invalid backup mode option ######
|
||||
ERROR: invalid backup-mode "bad"
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0007 ######
|
||||
###### delete failure without DATE ######
|
||||
ERROR: required backup ID not specified
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0008 ######
|
||||
###### syntax error in pg_probackup.conf ######
|
||||
WARNING: syntax error in " = INFINITE"
|
||||
ERROR: Required parameter not specified: BACKUP_MODE (-b, --backup-mode)
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0009 ######
|
||||
###### invalid value in pg_probackup.conf ######
|
||||
ERROR: invalid backup-mode ""
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0010 ######
|
||||
###### invalid value in pg_probackup.conf ######
|
||||
ERROR: invalid option "KEEP_DATA_GENERATIONS"
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0011 ######
|
||||
###### invalid value in pg_probackup.conf ######
|
||||
ERROR: option -C, --smooth-checkpoint should be a boolean: 'FOO'
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0012 ######
|
||||
###### invalid option in pg_probackup.conf ######
|
||||
ERROR: invalid option "TIMELINEID"
|
||||
1
|
||||
|
||||
###### COMMAND OPTION TEST-0013 ######
|
||||
###### check priority of several pg_probackup.conf files ######
|
||||
ERROR: invalid backup-mode "ENV_PATH"
|
||||
1
|
||||
|
@ -1,67 +0,0 @@
|
||||
\! bash sql/restore.sh
|
||||
###### RESTORE COMMAND TEST-0001 ######
|
||||
###### recovery to latest from full backup ######
|
||||
0
|
||||
0
|
||||
|
||||
###### RESTORE COMMAND TEST-0002 ######
|
||||
###### recovery to latest from full + page backups ######
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
###### RESTORE COMMAND TEST-0003 ######
|
||||
###### recovery to target timeline ######
|
||||
0
|
||||
0
|
||||
0
|
||||
checking recovery.conf...
|
||||
OK: recovery.conf has the given target timeline.
|
||||
|
||||
###### RESTORE COMMAND TEST-0004 ######
|
||||
###### recovery to target time ######
|
||||
0
|
||||
0
|
||||
|
||||
###### RESTORE COMMAND TEST-0005 ######
|
||||
###### recovery to target XID ######
|
||||
0
|
||||
0
|
||||
OK: xid options works well.
|
||||
|
||||
###### RESTORE COMMAND TEST-0006 ######
|
||||
###### recovery to latest from full + ptrack backups ######
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
###### RESTORE COMMAND TEST-0007 ######
|
||||
###### recovery to latest from full + ptrack + ptrack backups ######
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
###### RESTORE COMMAND TEST-0011 ######
|
||||
###### recovery in stream mode to latest from full + ptrack backups ######
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
###### RESTORE COMMAND TEST-0010 ######
|
||||
###### recovery to latest from full + page backups with loads when ptrack backup do ######
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
###### RESTORE COMMAND TEST-0009 ######
|
||||
###### recovery to latest from full + ptrack backups with loads when full backup do ######
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
###### RESTORE COMMAND TEST-0008 ######
|
||||
###### recovery with target inclusive false ######
|
||||
0
|
||||
0
|
||||
OK: inclusive=false works well.
|
@ -1,17 +0,0 @@
|
||||
\! bash sql/show.sh
|
||||
###### SHOW COMMAND TEST-0001 ######
|
||||
###### Status DONE and OK ######
|
||||
0
|
||||
NG: DONE status is not shown.
|
||||
OK: OK status is shown properly.
|
||||
|
||||
###### SHOW COMMAND TEST-0002 ######
|
||||
###### Status RUNNING ######
|
||||
OK: RUNNING status is shown properly.
|
||||
|
||||
###### SHOW COMMAND TEST-0003 ######
|
||||
###### Status CORRUPT ######
|
||||
0
|
||||
remove a file from backup intentionally
|
||||
NG: CORRUPT status is not shown.
|
||||
|
116
sql/backup.sh
116
sql/backup.sh
@ -1,116 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#============================================================================
|
||||
# This is a test script for backup command of pg_probackup.
|
||||
#============================================================================
|
||||
|
||||
# Load common rules
|
||||
. sql/common.sh backup
|
||||
|
||||
init_backup
|
||||
|
||||
echo '###### BACKUP COMMAND TEST-0001 ######'
|
||||
echo '###### full backup mode ######'
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0001-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0001-run.log 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.log 2>&1
|
||||
grep -c OK ${TEST_BASE}/TEST-0001.log
|
||||
grep OK ${TEST_BASE}/TEST-0001.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//'
|
||||
|
||||
echo '###### BACKUP COMMAND TEST-0002 ######'
|
||||
echo '###### page-level backup mode ######'
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0002-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0002-run.log 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.log 2>&1
|
||||
grep -c OK ${TEST_BASE}/TEST-0002.log
|
||||
grep OK ${TEST_BASE}/TEST-0002.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//'
|
||||
|
||||
echo '###### BACKUP COMMAND TEST-0003 ######'
|
||||
echo '###### full backup with smooth checkpoint ######'
|
||||
init_catalog
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -C -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0003-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0003-run.log 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0003.log 2>&1
|
||||
grep -c OK ${TEST_BASE}/TEST-0003.log
|
||||
grep OK ${TEST_BASE}/TEST-0003.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//'
|
||||
|
||||
#echo '###### BACKUP COMMAND TEST-0004 ######'
|
||||
#echo '###### full backup with keep-data-generations and keep-data-days ######'
|
||||
#init_catalog
|
||||
#pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $?
|
||||
#pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $?
|
||||
#pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $?
|
||||
#pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1
|
||||
#pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0004-before.log 2>&1
|
||||
#NUM_OF_FULL_BACKUPS_BEFORE=`grep OK ${TEST_BASE}/TEST-0004-before.log | grep FULL | wc -l | sed 's/^ *//'`
|
||||
#if [ ${NUM_OF_FULL_BACKUPS_BEFORE} -gt 2 ] ; then
|
||||
# echo "The number of existing full backups validated is greater than 2."
|
||||
# echo "OK. Let's try to test --keep-data-generations=1."
|
||||
#else
|
||||
# echo "The number of existing full backups validated is not greater than 2."
|
||||
# echo "NG. There was something wrong in preparation of this test."
|
||||
# pg_ctl stop -m immediate -D ${PGDATA_PATH} > /dev/null 2>&1
|
||||
# exit 1
|
||||
#fi
|
||||
## The actual value of NUM_OF_FULL_BACKUPS_BEFORE can vary on env, so commented out as default.
|
||||
##echo "Number of existing full backups validated: ${NUM_OF_FULL_BACKUPS_BEFORE}"
|
||||
#grep OK ${TEST_BASE}/TEST-0004-before.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//'
|
||||
#pg_probackup backup -B ${BACKUP_PATH} -b full --keep-data-days=-1 --keep-data-generations=1 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0005-run.log 2>&1;echo $?
|
||||
#pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0005-run.log 2>&1
|
||||
#pg_probackup show --show-all -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0004-after.log 2>&1
|
||||
#NUM_OF_FULL_BACKUPS_AFTER=`grep OK ${TEST_BASE}/TEST-0004-after.log | grep FULL | wc -l | sed 's/^ *//'`
|
||||
#echo "Number of remaining full backups validated: ${NUM_OF_FULL_BACKUPS_AFTER}"
|
||||
#NUM_OF_DELETED_BACKUPS=`grep DELETED ${TEST_BASE}/TEST-0004-after.log | wc -l | sed 's/^ *//'`
|
||||
#echo "Number of deleted backups : ${NUM_OF_DELETED_BACKUPS}"
|
||||
#grep OK ${TEST_BASE}/TEST-0004-after.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//'
|
||||
|
||||
echo '###### BACKUP COMMAND TEST-0005 ######'
|
||||
echo '###### switch backup mode from page to full ######'
|
||||
init_catalog
|
||||
echo 'page-level backup without validated full backup'
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0005.log 2>&1
|
||||
grep OK ${TEST_BASE}/TEST-0005.log | grep FULL | wc -l | sed 's/^ *//'
|
||||
grep ERROR ${TEST_BASE}/TEST-0005.log | grep INCR | wc -l | sed 's/^ *//'
|
||||
|
||||
echo '###### BACKUP COMMAND TEST-0006 ######'
|
||||
echo '###### ptrack backup mode ######'
|
||||
init_catalog
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0006-run.log 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0006.log 2>&1
|
||||
grep -c OK ${TEST_BASE}/TEST-0006.log
|
||||
grep OK ${TEST_BASE}/TEST-0006.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//'
|
||||
|
||||
echo '###### BACKUP COMMAND TEST-0007 ######'
|
||||
echo '###### ptrack multi thread backup mode ######'
|
||||
init_catalog
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.log 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0007-run.log 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0007.log 2>&1
|
||||
grep -c OK ${TEST_BASE}/TEST-0007.log
|
||||
grep OK ${TEST_BASE}/TEST-0007.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//'
|
||||
|
||||
echo '###### BACKUP COMMAND TEST-0008 ######'
|
||||
echo '###### ptrack multi thread backup mode + stream ######'
|
||||
init_catalog
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0008-run.log 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.log 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0008-run.log 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0008.log 2>&1
|
||||
grep -c OK ${TEST_BASE}/TEST-0008.log
|
||||
grep OK ${TEST_BASE}/TEST-0008.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//'
|
||||
|
||||
# cleanup
|
||||
## clean up the temporal test data
|
||||
pg_ctl stop -m immediate -D ${PGDATA_PATH} > /dev/null 2>&1
|
||||
rm -fr ${PGDATA_PATH}
|
||||
rm -fr ${BACKUP_PATH}
|
||||
rm -fr ${ARCLOG_PATH}
|
||||
rm -fr ${TBLSPC_PATH}
|
@ -1,2 +0,0 @@
|
||||
\! bash sql/backup.sh
|
||||
|
102
sql/common.sh
102
sql/common.sh
@ -1,102 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#============================================================================
|
||||
# Common setup rules for all tests
|
||||
#============================================================================
|
||||
|
||||
TEST_NAME=$1
|
||||
|
||||
# Unset environment variables usable by both Postgres and pg_probackup
|
||||
unset PGUSER
|
||||
unset PGPORT
|
||||
unset PGDATABASE
|
||||
unset BACKUP_MODE
|
||||
unset ARCLOG_PATH
|
||||
unset BACKUP_PATH
|
||||
unset SMOOTH_CHECKPOINT
|
||||
unset KEEP_DATA_GENERATIONS
|
||||
unset KEEP_DATA_DAYS
|
||||
unset RECOVERY_TARGET_TIME
|
||||
unset RECOVERY_TARGET_XID
|
||||
unset RECOVERY_TARGET_INCLUSIVE
|
||||
unset RECOVERY_TARGET_TIMELINE
|
||||
|
||||
# Data locations
|
||||
BASE_PATH=`pwd`
|
||||
TEST_BASE=${BASE_PATH}/results/${TEST_NAME}
|
||||
PGDATA_PATH=${TEST_BASE}/data
|
||||
BACKUP_PATH=${TEST_BASE}/backup
|
||||
ARCLOG_PATH=${BACKUP_PATH}/wal
|
||||
TBLSPC_PATH=${TEST_BASE}/tblspc
|
||||
TEST_PGPORT=54321
|
||||
export PGDATA=${PGDATA_PATH}
|
||||
|
||||
# Set of utility functions set across scripts to manage the tests
|
||||
# Check presence of pgbench command and initialize environment
|
||||
which pgbench > /dev/null 2>&1
|
||||
ERR_NUM=$?
|
||||
if [ $ERR_NUM != 0 ]
|
||||
then
|
||||
echo "pgbench is not installed in this environment."
|
||||
echo "It is needed in PATH for those regression tests."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function cleanup()
|
||||
{
|
||||
# cleanup environment
|
||||
pg_ctl stop -D ${PGDATA_PATH} -m immediate > /dev/null 2>&1
|
||||
for folder in ${PGDATA_PATH} ${BACKUP_PATH} ${ARCLOG_PATH} ${TBLSPC_PATH}; do
|
||||
rm -rf $folder
|
||||
mkdir -p $folder
|
||||
done
|
||||
}
|
||||
|
||||
function init_catalog()
|
||||
{
|
||||
rm -fr ${BACKUP_PATH}
|
||||
pg_probackup init -B ${BACKUP_PATH} --quiet
|
||||
}
|
||||
|
||||
function init_backup()
|
||||
{
|
||||
# cleanup environment
|
||||
cleanup
|
||||
|
||||
# create new database cluster
|
||||
initdb --no-locale -D ${PGDATA_PATH} > ${TEST_BASE}/initdb.log 2>&1
|
||||
cp $PGDATA_PATH/postgresql.conf $PGDATA_PATH/postgresql.conf_org
|
||||
cat << EOF >> $PGDATA_PATH/postgresql.conf
|
||||
port = ${TEST_PGPORT}
|
||||
logging_collector = on
|
||||
wal_level = hot_standby
|
||||
wal_log_hints = off
|
||||
archive_mode = on
|
||||
archive_command = 'cp %p ${ARCLOG_PATH}/%f'
|
||||
ptrack_enable = on
|
||||
max_wal_senders = 5
|
||||
wal_keep_segments = 32
|
||||
EOF
|
||||
|
||||
cat << EOF >> $PGDATA_PATH/pg_hba.conf
|
||||
local replication all trust
|
||||
host replication all 127.0.0.1/32 trust
|
||||
EOF
|
||||
# start PostgreSQL
|
||||
pg_ctl start -D ${PGDATA_PATH} -w -t 300 > /dev/null 2>&1
|
||||
pgbench -i -p ${TEST_PGPORT} -d postgres > ${TEST_BASE}/pgbench.log 2>&1
|
||||
|
||||
# init backup catalog
|
||||
init_catalog
|
||||
}
|
||||
|
||||
function get_time_last_backup()
|
||||
{
|
||||
name_os=`uname`
|
||||
if [ "$name_os" == "SunOS" ]
|
||||
then
|
||||
pg_probackup -B ${BACKUP_PATH} show | gtail -n +4 | head -n 1 | awk '{print($1)}'
|
||||
else
|
||||
pg_probackup -B ${BACKUP_PATH} show | tail -n +4 | head -n 1 | awk '{print($1)}'
|
||||
fi
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#============================================================================
|
||||
# This is a test script for delete command of pg_probackup.
|
||||
#============================================================================
|
||||
|
||||
# Load common rules
|
||||
. sql/common.sh delete
|
||||
|
||||
init_backup
|
||||
echo '###### DELETE COMMAND TEST-0001 ######'
|
||||
echo '###### delete full backups ######'
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
|
||||
FIRST_BACKUP_DATE=$(get_time_last_backup)
|
||||
pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
|
||||
SECOND_BACKUP_DATE=$(get_time_last_backup)
|
||||
pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
|
||||
THIRD_BACKUP_DATE=$(get_time_last_backup)
|
||||
|
||||
echo "try to delete the oldest backup"
|
||||
pg_probackup -B ${BACKUP_PATH} delete ${SECOND_BACKUP_DATE} > /dev/null 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.out.1 2>&1
|
||||
pg_probackup show -a -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.out.2 2>&1
|
||||
grep -c OK ${TEST_BASE}/TEST-0001.out.1
|
||||
grep -c DELETED ${TEST_BASE}/TEST-0001.out.2
|
||||
NUM_OF_DELETED_BACKUPS=`grep DELETED ${TEST_BASE}/TEST-0001.out.2 | wc -l | sed 's/^ *//'`
|
||||
echo "Number of deleted backups should be 1, is it so?: ${NUM_OF_DELETED_BACKUPS}"
|
||||
|
||||
init_backup
|
||||
echo '###### DELETE COMMAND TEST-0002 ######'
|
||||
echo '###### keep backups which are necessary for recovery ######'
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
|
||||
FIRST_BACKUP_DATE=$(get_time_last_backup)
|
||||
pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
|
||||
SECOND_BACKUP_DATE=$(get_time_last_backup)
|
||||
pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --quiet
|
||||
THIRD_BACKUP_DATE=$(get_time_last_backup)
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
|
||||
FOURTH_BACKUP_DATE=$(get_time_last_backup)
|
||||
|
||||
echo "try to delete before third backup"
|
||||
pg_probackup delete -B ${BACKUP_PATH} ${THIRD_BACKUP_DATE} > /dev/null 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.out.1 2>&1
|
||||
pg_probackup show -a -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.out.2 2>&1
|
||||
grep -c OK ${TEST_BASE}/TEST-0002.out.1
|
||||
grep -c DELETED ${TEST_BASE}/TEST-0002.out.2
|
||||
NUM_OF_DELETED_BACKUPS=`grep DELETED ${TEST_BASE}/TEST-0002.out.2 | wc -l | sed 's/^ *//'`
|
||||
echo "Number of deleted backups should be 1, is it so?: ${NUM_OF_DELETED_BACKUPS}"
|
||||
|
||||
init_backup
|
||||
# clean up the temporal test data
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
rm -fr ${PGDATA_PATH}
|
||||
rm -fr ${BACKUP_PATH}
|
||||
rm -fr ${ARCLOG_PATH}
|
||||
rm -fr ${SRVLOG_PATH}
|
||||
rm -fr ${TBLSPC_PATH}
|
@ -1 +0,0 @@
|
||||
\! bash sql/delete.sh
|
70
sql/init.sh
70
sql/init.sh
@ -1,70 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#============================================================================
|
||||
# This is a test script for init command of pg_probackup.
|
||||
#============================================================================
|
||||
|
||||
# Load common rules
|
||||
. sql/common.sh init
|
||||
|
||||
# clean and create database cluster
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
rm -fr ${PGDATA}
|
||||
rm -fr ${BACKUP_PATH}
|
||||
|
||||
initdb --no-locale > /dev/null 2>&1
|
||||
cp ${PGDATA}/postgresql.conf ${PGDATA}/postgresql.conf_org
|
||||
cat << EOF >> ${PGDATA}/postgresql.conf
|
||||
wal_level = hot_standby
|
||||
archive_mode = on
|
||||
archive_command = 'cp "%p" "${ARCLOG_PATH}/%f"'
|
||||
EOF
|
||||
|
||||
echo '###### INIT COMMAND TEST-0001 ######'
|
||||
echo '###### success with archive_command ######'
|
||||
pg_probackup -B ${BACKUP_PATH} init --quiet;echo $?
|
||||
find results/init/backup | xargs ls -Fd | sort
|
||||
|
||||
echo '###### INIT COMMAND TEST-0002 ######'
|
||||
echo '###### success with archive_command and log_directory ######'
|
||||
rm -rf ${BACKUP_PATH}
|
||||
cp ${PGDATA_PATH}/postgresql.conf_org ${PGDATA_PATH}/postgresql.conf
|
||||
cat << EOF >> ${PGDATA}/postgresql.conf
|
||||
wal_level = hot_standby
|
||||
archive_mode = on
|
||||
archive_command = 'cp "%p" "${ARCLOG_PATH}/%f"'
|
||||
log_directory = '${SRVLOG_PATH}'
|
||||
EOF
|
||||
pg_probackup -B ${BACKUP_PATH} init --quiet;echo $?
|
||||
find results/init/backup | xargs ls -Fd | sort
|
||||
|
||||
echo '###### INIT COMMAND TEST-0003 ######'
|
||||
echo '###### success without archive_command ######'
|
||||
rm -rf ${BACKUP_PATH}
|
||||
cp ${PGDATA_PATH}/postgresql.conf_org ${PGDATA_PATH}/postgresql.conf
|
||||
cat << EOF >> ${PGDATA}/postgresql.conf
|
||||
wal_level = hot_standby
|
||||
archive_mode = on
|
||||
log_directory = '${SRVLOG_PATH}'
|
||||
EOF
|
||||
pg_probackup -B ${BACKUP_PATH} init --quiet;echo $?
|
||||
find results/init/backup | xargs ls -Fd | sort
|
||||
|
||||
echo '###### INIT COMMAND TEST-0004 ######'
|
||||
echo '###### failure with backup catalog already existed ######'
|
||||
pg_probackup -B ${BACKUP_PATH} init;echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### INIT COMMAND TEST-0005 ######'
|
||||
echo '###### failure with backup catalog should be given as absolute path ######'
|
||||
rm -rf ${BACKUP_PATH}
|
||||
pg_probackup --backup-path=resuts/init/backup init;echo $?
|
||||
echo ''
|
||||
|
||||
|
||||
# clean up the temporal test data
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
rm -fr ${PGDATA}
|
||||
rm -fr ${BACKUP_PATH}
|
||||
rm -fr ${ARCLOG_PATH}
|
||||
rm -fr ${SRVLOG_PATH}
|
@ -1 +0,0 @@
|
||||
\! bash sql/init.sh
|
@ -1,92 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#============================================================================
|
||||
# This is a test script for options of pg_probackup.
|
||||
#============================================================================
|
||||
|
||||
# Load common rules
|
||||
. sql/common.sh option
|
||||
|
||||
cleanup
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0001 ######'
|
||||
echo '###### help option ######'
|
||||
pg_probackup --help;echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0002 ######'
|
||||
echo '###### version option ######'
|
||||
pg_probackup --version;echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0003 ######'
|
||||
echo '###### backup command failure without backup path option ######'
|
||||
pg_probackup backup -b full -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0004 ######'
|
||||
echo '###### backup command failure without backup mode option ######'
|
||||
pg_probackup backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0005 ######'
|
||||
echo '###### backup command failure with invalid backup mode option ######'
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b bad -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0007 ######'
|
||||
echo '###### delete failure without DATE ######'
|
||||
pg_probackup delete -B ${BACKUP_PATH};echo $?
|
||||
echo ''
|
||||
|
||||
init_backup
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0008 ######'
|
||||
echo '###### syntax error in pg_probackup.conf ######'
|
||||
echo " = INFINITE" >> ${BACKUP_PATH}/pg_probackup.conf
|
||||
pg_probackup backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0009 ######'
|
||||
echo '###### invalid value in pg_probackup.conf ######'
|
||||
init_catalog
|
||||
echo "BACKUP_MODE=" >> ${BACKUP_PATH}/pg_probackup.conf
|
||||
pg_probackup backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0010 ######'
|
||||
echo '###### invalid value in pg_probackup.conf ######'
|
||||
init_catalog
|
||||
echo "KEEP_DATA_GENERATIONS=TRUE" >> ${BACKUP_PATH}/pg_probackup.conf
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0011 ######'
|
||||
echo '###### invalid value in pg_probackup.conf ######'
|
||||
init_catalog
|
||||
echo "SMOOTH_CHECKPOINT=FOO" >> ${BACKUP_PATH}/pg_probackup.conf
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0012 ######'
|
||||
echo '###### invalid option in pg_probackup.conf ######'
|
||||
init_catalog
|
||||
echo "TIMELINEID=1" >> ${BACKUP_PATH}/pg_probackup.conf
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
echo '###### COMMAND OPTION TEST-0013 ######'
|
||||
echo '###### check priority of several pg_probackup.conf files ######'
|
||||
init_catalog
|
||||
mkdir -p ${BACKUP_PATH}/conf_path_a
|
||||
echo "BACKUP_MODE=ENV_PATH" > ${BACKUP_PATH}/pg_probackup.conf
|
||||
echo "BACKUP_MODE=ENV_PATH_A" > ${BACKUP_PATH}/conf_path_a/pg_probackup.conf
|
||||
pg_probackup backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
|
||||
echo ''
|
||||
|
||||
# clean up the temporal test data
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
rm -fr ${PGDATA_PATH}
|
||||
rm -fr ${BACKUP_PATH}
|
||||
rm -fr ${ARCLOG_PATH}
|
||||
rm -fr ${TBLSPC_PATH}
|
@ -1 +0,0 @@
|
||||
\! bash sql/option.sh
|
275
sql/restore.sh
275
sql/restore.sh
@ -1,275 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#============================================================================
|
||||
# This is a test script for restore command of pg_probackup.
|
||||
#============================================================================
|
||||
|
||||
# Load common rules
|
||||
. sql/common.sh restore
|
||||
|
||||
# Parameters exclusive to this test
|
||||
SCALE=2
|
||||
|
||||
# Create some objects expected by pgbench
|
||||
pgbench_objs()
|
||||
{
|
||||
NUM=$1
|
||||
rm -rf ${TBLSPC_PATH}/pgbench
|
||||
mkdir -p ${TBLSPC_PATH}/pgbench
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d postgres > /dev/null 2>&1 <<EOF
|
||||
CREATE TABLESPACE pgbench LOCATION '${TBLSPC_PATH}/pgbench';
|
||||
CREATE DATABASE pgbench TABLESPACE = pgbench;
|
||||
EOF
|
||||
|
||||
pgbench -i -s ${SCALE} -p ${TEST_PGPORT} -d pgbench > ${TEST_BASE}/pgbench-${NUM}.log 2>&1
|
||||
}
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0001 ######'
|
||||
echo '###### recovery to latest from full backup ######'
|
||||
init_backup
|
||||
pgbench_objs 0001
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0001-before.out
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0001-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0001-run.out 2>&1
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} -j 4 --verbose >> ${TEST_BASE}/TEST-0001-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0001-after.out
|
||||
diff ${TEST_BASE}/TEST-0001-before.out ${TEST_BASE}/TEST-0001-after.out
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0002 ######'
|
||||
echo '###### recovery to latest from full + page backups ######'
|
||||
init_backup
|
||||
pgbench_objs 0002
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0002-before.out
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} -j 4 --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0002-after.out
|
||||
diff ${TEST_BASE}/TEST-0002-before.out ${TEST_BASE}/TEST-0002-after.out
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0003 ######'
|
||||
echo '###### recovery to target timeline ######'
|
||||
init_backup
|
||||
pgbench_objs 0003
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0003-before.out
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1
|
||||
TARGET_TLI=`pg_controldata | grep " TimeLineID:" | awk '{print $4}'`
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --timeline=${TARGET_TLI} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $?
|
||||
echo "checking recovery.conf..."
|
||||
TARGET_TLI_IN_RECOVERY_CONF=`grep "recovery_target_timeline = " ${PGDATA_PATH}/recovery.conf | awk '{print $3}' | sed -e "s/'//g"`
|
||||
if [ ${TARGET_TLI} = ${TARGET_TLI_IN_RECOVERY_CONF} ]; then
|
||||
echo 'OK: recovery.conf has the given target timeline.'
|
||||
else
|
||||
echo 'NG: recovery.conf does not have the given target timeline.'
|
||||
pg_ctl stop -m immediate -D ${PGDATA_PATH}
|
||||
exit 1
|
||||
fi
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0003-after.out
|
||||
diff ${TEST_BASE}/TEST-0003-before.out ${TEST_BASE}/TEST-0003-after.out
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0004 ######'
|
||||
echo '###### recovery to target time ######'
|
||||
init_backup
|
||||
pgbench_objs 0004
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0004-before.out
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0004-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0004-run.out 2>&1
|
||||
TARGET_TIME=`date +"%Y-%m-%d %H:%M:%S"`
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --time="${TARGET_TIME}" --verbose >> ${TEST_BASE}/TEST-0004-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0004-after.out
|
||||
diff ${TEST_BASE}/TEST-0004-before.out ${TEST_BASE}/TEST-0004-after.out
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0005 ######'
|
||||
echo '###### recovery to target XID ######'
|
||||
init_backup
|
||||
pgbench_objs 0005
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "CREATE TABLE tbl0005 (a text);" > /dev/null 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0005-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0005-run.out 2>&1
|
||||
pgbench -p ${TEST_PGPORT} pgbench > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0005-before.out
|
||||
TARGET_XID=`psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -tAq -c "INSERT INTO tbl0005 VALUES ('inserted') RETURNING (xmin);"`
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
# Enforce segment to be archived to ensure that recovery goes up to the
|
||||
# wanted point. There is no way to ensure that all segments needed have
|
||||
# been archived up to the xmin point saved earlier without that.
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c 'SELECT pg_switch_xlog()' > /dev/null 2>&1
|
||||
# Fast mode is used to ensure that the last segment is archived as well.
|
||||
pg_ctl stop -m fast > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --xid="${TARGET_XID}" --verbose >> ${TEST_BASE}/TEST-0005-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0005-after.out
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM tbl0005;" > ${TEST_BASE}/TEST-0005-tbl.dump
|
||||
diff ${TEST_BASE}/TEST-0005-before.out ${TEST_BASE}/TEST-0005-after.out
|
||||
if grep "inserted" ${TEST_BASE}/TEST-0005-tbl.dump > /dev/null ; then
|
||||
echo 'OK: xid options works well.'
|
||||
else
|
||||
echo 'NG: xid options does not work well.'
|
||||
pg_ctl stop -m immediate -D ${PGDATA_PATH} > /dev/null 2>&1
|
||||
exit 1
|
||||
fi
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0006 ######'
|
||||
echo '###### recovery to latest from full + ptrack backups ######'
|
||||
init_backup
|
||||
pgbench_objs 0006
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0006-before.out
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0006-after.out
|
||||
diff ${TEST_BASE}/TEST-0006-before.out ${TEST_BASE}/TEST-0006-after.out
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0007 ######'
|
||||
echo '###### recovery to latest from full + ptrack + ptrack backups ######'
|
||||
init_backup
|
||||
pgbench_objs 0007
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0007-show.out 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0007-before.out
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0007-after.out
|
||||
diff ${TEST_BASE}/TEST-0007-before.out ${TEST_BASE}/TEST-0007-after.out
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0011 ######'
|
||||
echo '###### recovery in stream mode to latest from full + ptrack backups ######'
|
||||
init_backup
|
||||
pgbench_objs 0006
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0011-before.out
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --stream --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
sleep 5
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0011-after.out
|
||||
diff ${TEST_BASE}/TEST-0011-before.out ${TEST_BASE}/TEST-0011-after.out
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0010 ######'
|
||||
echo '###### recovery to latest from full + page backups with loads when ptrack backup do ######'
|
||||
init_backup
|
||||
pgbench_objs 0010
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench -c 4 -T 8 > /dev/null 2>&1 &
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1
|
||||
sleep 12
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(bbalance) FROM pgbench_branches;" > ${TEST_BASE}/TEST-0010-count1.out
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(delta) FROM pgbench_history;" > ${TEST_BASE}/TEST-0010-count2.out
|
||||
diff ${TEST_BASE}/TEST-0010-count1.out ${TEST_BASE}/TEST-0010-count2.out
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(bbalance) FROM pgbench_branches;" > ${TEST_BASE}/TEST-0010-count1.out
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(delta) FROM pgbench_history;" > ${TEST_BASE}/TEST-0010-count2.out
|
||||
diff ${TEST_BASE}/TEST-0010-count1.out ${TEST_BASE}/TEST-0010-count2.out
|
||||
|
||||
echo ''
|
||||
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0009 ######'
|
||||
echo '###### recovery to latest from full + ptrack backups with loads when full backup do ######'
|
||||
init_backup
|
||||
pgbench_objs 0009
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench -c 4 -T 8 > /dev/null 2>&1 &
|
||||
#PGBENCH_PID=$!
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1
|
||||
#kill $PGBENCH_PID 2> /dev/null
|
||||
sleep 12
|
||||
#psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT count(*) FROM pgbench_history;" > ${TEST_BASE}/TEST-0009-count1.out
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(bbalance) FROM pgbench_branches;" > ${TEST_BASE}/TEST-0009-count1.out
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(delta) FROM pgbench_history;" > ${TEST_BASE}/TEST-0009-count2.out
|
||||
diff ${TEST_BASE}/TEST-0009-count1.out ${TEST_BASE}/TEST-0009-count2.out
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(bbalance) FROM pgbench_branches;" > ${TEST_BASE}/TEST-0009-count1.out
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(delta) FROM pgbench_history;" > ${TEST_BASE}/TEST-0009-count2.out
|
||||
diff ${TEST_BASE}/TEST-0009-count1.out ${TEST_BASE}/TEST-0009-count2.out
|
||||
echo ''
|
||||
|
||||
echo '###### RESTORE COMMAND TEST-0008 ######'
|
||||
echo '###### recovery with target inclusive false ######'
|
||||
init_backup
|
||||
pgbench_objs 0008
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "CREATE TABLE tbl0008 (a text);" > /dev/null 2>&1
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.out 2>&1;echo $?
|
||||
pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1
|
||||
pgbench -p ${TEST_PGPORT} pgbench > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0008-before.out
|
||||
TARGET_XID=`psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -tAq -c "INSERT INTO tbl0008 VALUES ('inserted') RETURNING (xmin);"`
|
||||
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
|
||||
# Enforce segment to be archived to ensure that recovery goes up to the
|
||||
# wanted point. There is no way to ensure that all segments needed have
|
||||
# been archived up to the xmin point saved earlier without that.
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c 'SELECT pg_switch_xlog()' > /dev/null 2>&1
|
||||
# Fast mode is used to ensure that the last segment is archived as well.
|
||||
pg_ctl stop -m fast > /dev/null 2>&1
|
||||
pg_probackup restore -B ${BACKUP_PATH} --xid="${TARGET_XID}" --inclusive=false --verbose >> ${TEST_BASE}/TEST-0008-run.out 2>&1;echo $?
|
||||
pg_ctl start -w -t 600 > /dev/null 2>&1
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0008-after.out
|
||||
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM tbl0008;" > ${TEST_BASE}/TEST-0008-tbl.dump
|
||||
diff ${TEST_BASE}/TEST-0008-before.out ${TEST_BASE}/TEST-0008-after.out
|
||||
if grep "inserted" ${TEST_BASE}/TEST-0008-tbl.dump > /dev/null ; then
|
||||
echo 'NG: inclusive=false does not work well.'
|
||||
else
|
||||
echo 'OK: inclusive=false works well.'
|
||||
pg_ctl stop -m immediate -D ${PGDATA_PATH} > /dev/null 2>&1
|
||||
exit 1
|
||||
fi
|
||||
echo ''
|
||||
|
||||
|
||||
# clean up the temporal test data
|
||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||
rm -fr ${PGDATA_PATH}
|
||||
rm -fr ${BACKUP_PATH}
|
||||
rm -fr ${ARCLOG_PATH}
|
||||
rm -fr ${TBLSPC_PATH}
|
@ -1,2 +0,0 @@
|
||||
\! bash sql/restore.sh
|
||||
|
73
sql/show.sh
73
sql/show.sh
@ -1,73 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#============================================================================
|
||||
# This is a test script for show command of pg_probackup.
|
||||
#============================================================================
|
||||
|
||||
# Load common rules
|
||||
. sql/common.sh show
|
||||
|
||||
init_backup
|
||||
|
||||
echo '###### SHOW COMMAND TEST-0001 ######'
|
||||
echo '###### Status DONE and OK ######'
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $?
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001-show.out.1 2>&1
|
||||
if grep "DONE" ${TEST_BASE}/TEST-0001-show.out.1 > /dev/null ; then
|
||||
echo 'OK: DONE status is shown properly.'
|
||||
else
|
||||
echo 'NG: DONE status is not shown.'
|
||||
fi
|
||||
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001-show.out.2 2>&1
|
||||
if grep "OK" ${TEST_BASE}/TEST-0001-show.out.2 > /dev/null ; then
|
||||
echo 'OK: OK status is shown properly.'
|
||||
else
|
||||
echo 'NG: OK status is not shown.'
|
||||
fi
|
||||
echo ''
|
||||
|
||||
echo '###### SHOW COMMAND TEST-0002 ######'
|
||||
echo '###### Status RUNNING ######'
|
||||
init_catalog
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet &
|
||||
sleep 1
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002-show.out 2>&1
|
||||
if grep "RUNNING" ${TEST_BASE}/TEST-0002-show.out > /dev/null ; then
|
||||
echo 'OK: RUNNING status is shown properly.'
|
||||
else
|
||||
echo 'NG: RUNNING status is not shown.'
|
||||
fi
|
||||
counter=0
|
||||
# Wait for backup to finish properly before moving on to next test
|
||||
while [[ `pg_probackup show -B ${BACKUP_PATH}` == *"RUNNING"* ]]; do
|
||||
if [ $counter -gt 60 ] ; then
|
||||
echo "Backup took too long to finish"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
counter=$(($counter + 1))
|
||||
done
|
||||
echo ''
|
||||
|
||||
echo '###### SHOW COMMAND TEST-0003 ######'
|
||||
echo '###### Status CORRUPT ######'
|
||||
init_catalog
|
||||
pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $?
|
||||
echo 'remove a file from backup intentionally'
|
||||
rm -f `find ${BACKUP_PATH} -name postgresql.conf`
|
||||
|
||||
pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0003-show.out 2>&1
|
||||
if grep "CORRUPT" ${TEST_BASE}/TEST-0003-show.out > /dev/null ; then
|
||||
echo 'OK: CORRUPT status is shown properly.'
|
||||
else
|
||||
echo 'NG: CORRUPT status is not shown.'
|
||||
fi
|
||||
echo ''
|
||||
|
||||
# clean up the temporal test data
|
||||
pg_ctl stop -D ${PGDATA_PATH} -m immediate > /dev/null 2>&1
|
||||
rm -fr ${PGDATA_PATH}
|
||||
rm -fr ${BACKUP_PATH}
|
||||
rm -fr ${ARCLOG_PATH}
|
||||
rm -fr ${TBLSPC_PATH}
|
@ -1 +0,0 @@
|
||||
\! bash sql/show.sh
|
Loading…
Reference in New Issue
Block a user