1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-09 14:45:47 +02:00
pg_probackup/sql/delete.sh
Michael Paquier 3ac6d13329 Remove --compress-data/-Z
Performance of compression is quite questionable on many objects like
that and makes the routines aimed at managing file copy, backup and restore
more complicated than they should be.

This commit results in a largely simplified code in data.c, which will
be helpful when integrating differential backup using WAL file lookup.
2016-01-14 15:19:38 +09:00

66 lines
2.9 KiB
Bash

#!/bin/bash
#============================================================================
# This is a test script for delete command of pg_arman.
#============================================================================
# Load common rules
. sql/common.sh delete
init_backup
echo '###### DELETE COMMAND TEST-0001 ######'
echo '###### delete full backups ######'
FIRST_BACKUP_DATE=`date +"%Y-%m-%d %H:%M:%S"`
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1
SECOND_BACKUP_DATE=`date +"%Y-%m-%d %H:%M:%S"`
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1
THIRD_BACKUP_DATE=`date +"%Y-%m-%d %H:%M:%S"`
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
pg_arman validate -B ${BACKUP_PATH} --quiet
echo "try to delete the oldest backup"
pg_arman -B ${BACKUP_PATH} delete ${SECOND_BACKUP_DATE} > /dev/null 2>&1
pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.out.1 2>&1
pg_arman 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 ######'
FIRST_BACKUP_DATE=`date +"%Y-%m-%d %H:%M:%S"`
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1
SECOND_BACKUP_DATE=`date +"%Y-%m-%d %H:%M:%S"`
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
pg_arman validate -B ${BACKUP_PATH} --quiet
pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1
THIRD_BACKUP_DATE=`date +"%Y-%m-%d %H:%M:%S"`
pg_arman backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --quiet
pg_arman validate -B ${BACKUP_PATH} --quiet
FOURTH_BACKUP_DATE=`date +"%Y-%m-%d %H:%M:%S"`
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet
pg_arman validate -B ${BACKUP_PATH} --quiet
echo "try to delete before third backup"
pg_arman delete -B ${BACKUP_PATH} ${THIRD_BACKUP_DATE} > /dev/null 2>&1
pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.out.1 2>&1
pg_arman 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}