diff --git a/sql/common.sh b/sql/common.sh index ac11a2cf..dd994400 100644 --- a/sql/common.sh +++ b/sql/common.sh @@ -83,3 +83,8 @@ EOF # init backup catalog init_catalog } + +function get_time_last_backup() +{ + pg_arman -B ${BACKUP_PATH} show | tail -n +4 | head -n 1 | awk '{print($1, $2)}' +} diff --git a/sql/delete.sh b/sql/delete.sh index dc5904ac..41ca57a4 100644 --- a/sql/delete.sh +++ b/sql/delete.sh @@ -10,14 +10,14 @@ 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 +FIRST_BACKUP_DATE=$(get_time_last_backup) 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 +SECOND_BACKUP_DATE=$(get_time_last_backup) 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 +THIRD_BACKUP_DATE=$(get_time_last_backup) pg_arman validate -B ${BACKUP_PATH} --quiet echo "try to delete the oldest backup" @@ -32,18 +32,18 @@ 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 +FIRST_BACKUP_DATE=$(get_time_last_backup) 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 +SECOND_BACKUP_DATE=$(get_time_last_backup) 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 +THIRD_BACKUP_DATE=$(get_time_last_backup) 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 +FOURTH_BACKUP_DATE=$(get_time_last_backup) pg_arman validate -B ${BACKUP_PATH} --quiet echo "try to delete before third backup" diff --git a/sql/show.sh b/sql/show.sh index e7b21d1d..d94ad238 100644 --- a/sql/show.sh +++ b/sql/show.sh @@ -70,8 +70,8 @@ echo '###### Status DELETED ######' init_catalog pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $? pg_arman validate -B ${BACKUP_PATH} --quiet > /dev/null 2>&1;echo $? -DELETE_DATE=`date +"%Y-%m-%d %H:%M:%S"` pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $? +DELETE_DATE=$(get_time_last_backup) pg_arman validate -B ${BACKUP_PATH} --quiet > /dev/null 2>&1;echo $? pg_arman delete ${DELETE_DATE} -B ${BACKUP_PATH} > /dev/null 2>&1;echo $? pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0004-show.out 2>&1