-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete target backup (improvements) (#917)
* Delete the dependant delta backups when no find-full flag is specified * Replace --find-full with FIND_FULL to match the other delete commands * Add docs * Add integration test * Add FIND_FULL integration test
- Loading branch information
1 parent
739e5a2
commit 6bcccfb
Showing
13 changed files
with
314 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
docker/pg_tests/Dockerfile_delete_target_delta_find_full_test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM wal-g/docker_prefix:latest | ||
|
||
CMD su postgres -c "/tmp/tests/delete_target_delta_find_full_test.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM wal-g/docker_prefix:latest | ||
|
||
CMD su postgres -c "/tmp/tests/delete_target_delta_test.sh" |
3 changes: 3 additions & 0 deletions
3
docker/pg_tests/scripts/configs/delete_target_delta_find_full_test_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"WALG_DELTA_MAX_STEPS": "100", | ||
"WALE_S3_PREFIX": "s3://deletetargetbucket", | ||
"WALG_USE_WAL_DELTA": "true" |
3 changes: 3 additions & 0 deletions
3
docker/pg_tests/scripts/configs/delete_target_delta_test_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"WALG_DELTA_MAX_STEPS": "100", | ||
"WALE_S3_PREFIX": "s3://deletetargetbucket", | ||
"WALG_USE_WAL_DELTA": "true" |
76 changes: 76 additions & 0 deletions
76
docker/pg_tests/scripts/tests/delete_target_delta_find_full_test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/sh | ||
set -e -x | ||
CONFIG_FILE="/tmp/configs/delete_target_delta_find_full_test_config.json" | ||
COMMON_CONFIG="/tmp/configs/common_config.json" | ||
TMP_CONFIG="/tmp/configs/tmp_config.json" | ||
cat ${CONFIG_FILE} > ${TMP_CONFIG} | ||
echo "," >> ${TMP_CONFIG} | ||
cat ${COMMON_CONFIG} >> ${TMP_CONFIG} | ||
/tmp/scripts/wrap_config_file.sh ${TMP_CONFIG} | ||
|
||
/usr/lib/postgresql/10/bin/initdb ${PGDATA} | ||
|
||
echo "archive_mode = on" >> /var/lib/postgresql/10/main/postgresql.conf | ||
echo "archive_command = '/usr/bin/timeout 600 /usr/bin/wal-g --config=${TMP_CONFIG} wal-push %p'" >> /var/lib/postgresql/10/main/postgresql.conf | ||
echo "archive_timeout = 600" >> /var/lib/postgresql/10/main/postgresql.conf | ||
|
||
/usr/lib/postgresql/10/bin/pg_ctl -D ${PGDATA} -w start | ||
|
||
/tmp/scripts/wait_while_pg_not_ready.sh | ||
|
||
wal-g --config=${TMP_CONFIG} delete everything FORCE --confirm | ||
|
||
# create full backup and incremental | ||
for i in 1 2 | ||
do | ||
pgbench -i -s 1 postgres & | ||
sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} | ||
done | ||
|
||
# remember the backup-list output | ||
# later in the test we create new backups which should be deleted so lists should be identical | ||
lines_before_delete=`wal-g --config=${TMP_CONFIG} backup-list | wc -l` | ||
wal-g --config=${TMP_CONFIG} backup-list | tail -n 2 > /tmp/list_before_delete | ||
|
||
# create one full and two increments | ||
for i in 1 2 3 | ||
do | ||
if [ $i -eq 1 ]; then | ||
modifier='--full' | ||
else | ||
modifier='' | ||
fi | ||
pgbench -i -s 1 postgres & | ||
sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} ${modifier} | ||
done | ||
|
||
# get the name of the second incremental backup | ||
SECOND_INCREMENT=$(wal-g --config=${TMP_CONFIG} backup-list | awk 'NR==5 {print $1}') | ||
|
||
# make two increments from the SECOND_INCREMENT | ||
pgbench -i -s 1 postgres & sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} --delta-from-name ${SECOND_INCREMENT} | ||
|
||
pgbench -i -s 1 postgres & sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} --delta-from-name ${SECOND_INCREMENT} | ||
|
||
# delete the SECOND_INCREMENT with FIND_FULL, should leave only the first full backup w/ first increment | ||
wal-g --config=${TMP_CONFIG} delete target FIND_FULL ${SECOND_INCREMENT} --confirm | ||
|
||
lines_after_delete=`wal-g --config=${TMP_CONFIG} backup-list | wc -l` | ||
wal-g --config=${TMP_CONFIG} backup-list | tail -n 2 > /tmp/list_after_delete | ||
|
||
if [ $(($lines_before_delete)) -ne $lines_after_delete ]; | ||
then | ||
echo $(($lines_before_delete)) > /tmp/before_delete | ||
echo $lines_after_delete > /tmp/after_delete | ||
echo "Wrong number of deleted lines" | ||
diff /tmp/before_delete /tmp/after_delete | ||
fi | ||
|
||
|
||
diff /tmp/list_before_delete /tmp/list_after_delete | ||
/tmp/scripts/drop_pg.sh | ||
rm ${TMP_CONFIG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/sh | ||
set -e -x | ||
CONFIG_FILE="/tmp/configs/delete_target_delta_test_config.json" | ||
COMMON_CONFIG="/tmp/configs/common_config.json" | ||
TMP_CONFIG="/tmp/configs/tmp_config.json" | ||
cat ${CONFIG_FILE} > ${TMP_CONFIG} | ||
echo "," >> ${TMP_CONFIG} | ||
cat ${COMMON_CONFIG} >> ${TMP_CONFIG} | ||
/tmp/scripts/wrap_config_file.sh ${TMP_CONFIG} | ||
|
||
/usr/lib/postgresql/10/bin/initdb ${PGDATA} | ||
|
||
echo "archive_mode = on" >> /var/lib/postgresql/10/main/postgresql.conf | ||
echo "archive_command = '/usr/bin/timeout 600 /usr/bin/wal-g --config=${TMP_CONFIG} wal-push %p'" >> /var/lib/postgresql/10/main/postgresql.conf | ||
echo "archive_timeout = 600" >> /var/lib/postgresql/10/main/postgresql.conf | ||
|
||
/usr/lib/postgresql/10/bin/pg_ctl -D ${PGDATA} -w start | ||
|
||
/tmp/scripts/wait_while_pg_not_ready.sh | ||
|
||
wal-g --config=${TMP_CONFIG} delete everything FORCE --confirm | ||
|
||
# create one base backup and one increment | ||
for i in 1 2 | ||
do | ||
pgbench -i -s 1 postgres & | ||
sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} | ||
done | ||
|
||
# remember the name of the first increment | ||
FIRST_INCREMENT=$(wal-g --config=${TMP_CONFIG} backup-list | awk 'END {print $1}') | ||
|
||
# make the second full backup | ||
pgbench -i -s 1 postgres & sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} --full | ||
|
||
# make the increment from the second full backup | ||
pgbench -i -s 1 postgres & sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} | ||
|
||
# remember the backup-list output with two full backups and two increments. | ||
# later in the test we create new backups which should be deleted so lists should be identical | ||
lines_before_delete=`wal-g --config=${TMP_CONFIG} backup-list | wc -l` | ||
wal-g --config=${TMP_CONFIG} backup-list | tail -n 4 > /tmp/list_before_delete | ||
|
||
# now make increment from the FIRST_INCREMENT, which will be deleted later | ||
pgbench -i -s 1 postgres & sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} --delta-from-name ${FIRST_INCREMENT} | ||
INCREMENT_TO_DELETE=$(wal-g --config=${TMP_CONFIG} backup-list | awk 'END {print $1}') | ||
|
||
# make the increment from the INCREMENT_TO_DELETE | ||
pgbench -i -s 1 postgres & sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} --delta-from-name ${INCREMENT_TO_DELETE} | ||
|
||
# make one more increment from the INCREMENT_TO_DELETE | ||
pgbench -i -s 1 postgres & sleep 1 | ||
wal-g --config=${TMP_CONFIG} backup-push ${PGDATA} --delta-from-name ${INCREMENT_TO_DELETE} | ||
|
||
# delete the INCREMENT_TO_DELETE, should leave only the first full backup w/ first increment and the second full backup w/ first increment | ||
wal-g --config=${TMP_CONFIG} delete target ${INCREMENT_TO_DELETE} --confirm | ||
|
||
lines_after_delete=`wal-g --config=${TMP_CONFIG} backup-list | wc -l` | ||
wal-g --config=${TMP_CONFIG} backup-list | tail -n 4 > /tmp/list_after_delete | ||
|
||
if [ $(($lines_before_delete)) -ne $lines_after_delete ]; | ||
then | ||
echo $(($lines_before_delete)) > /tmp/before_delete | ||
echo $lines_after_delete > /tmp/after_delete | ||
echo "Wrong number of deleted lines" | ||
diff /tmp/before_delete /tmp/after_delete | ||
fi | ||
|
||
|
||
diff /tmp/list_before_delete /tmp/list_after_delete | ||
/tmp/scripts/drop_pg.sh | ||
rm ${TMP_CONFIG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.