#!/usr/bin/env sh if [ -d resources/test-data/pg-backups/ ]; then rm -r resources/test-data/pg-backups/ fi mkdir -p resources/test-data/pg-backups/ cd resources/test-data/pg-backups/ || exit # Missing files mkdir missing # Files are too small (and invalid dumps, but we don't check that here) mkdir too-small cd too-small || exit touch -d "1 day ago" pg_dump_1.sql touch -d "2 day ago" pg_dump_2.sql cd .. || exit # Valid SQL mkdir valid-sql cd valid-sql || exit cp ../../../../tests/data/pg_dump.sql pg_dump_1.sql cp ../../../../tests/data/pg_dump.sql pg_dump_2.sql touch -d "1 day ago" pg_dump_1.sql touch -d "2 day ago" pg_dump_2.sql cd .. || exit # Valid custom mkdir valid-custom cd valid-custom || exit cp ../../../../tests/data/pg_dump.dump pg_dump_1.dump cp ../../../../tests/data/pg_dump.dump pg_dump_2.dump touch -d "1 day ago" pg_dump_1.dump touch -d "2 day ago" pg_dump_2.dump cd .. || exit # Valid tar mkdir valid-tar cd valid-tar cp ../../../../tests/data/pg_dump.tar pg_dump_1.tar cp ../../../../tests/data/pg_dump.tar pg_dump_2.tar touch -d "1 day ago" pg_dump_1.tar touch -d "2 day ago" pg_dump_2.tar cd .. || exit # Valid with compression mkdir valid-compressed cd valid-compressed || exit cp ../../../../tests/data/pg_dump.dump pg_dump_1.dump cp ../../../../tests/data/pg_dump.dump pg_dump_2.dump gzip pg_dump_1.dump gzip pg_dump_2.dump touch -d "1 day ago" pg_dump_1.dump.gz touch -d "2 day ago" pg_dump_2.dump.gz cd .. || exit # Corrupted file mkdir corrupted cd corrupted || exit cp ../../../../tests/data/pg_dump.dump pg_dump.dump tail -c +5 pg_dump.dump | sponge pg_dump.dump touch -d "1 day ago" pg_dump.dump cd .. || exit # All valid but too old mkdir valid-but-too-old cd valid-but-too-old || exit cp ../../../../tests/data/pg_dump.sql pg_dump_1.sql cp ../../../../tests/data/pg_dump.sql pg_dump_2.sql touch -d "4 days ago" pg_dump_1.sql touch -d "5 days ago" pg_dump_2.sql cd .. || exit # Recent enough are corrupted, but older ones are not mkdir new-corrupted cd new-corrupted || exit cp ../../../../tests/data/pg_dump.dump pg_dump_1.dump cp ../../../../tests/data/pg_dump.dump pg_dump_2.dump cp ../../../../tests/data/pg_dump.dump pg_dump_4.dump cp ../../../../tests/data/pg_dump.dump pg_dump_5.dump tail -c +5 pg_dump_1.dump | sponge pg_dump_1.dump tail -c +5 pg_dump_2.dump | sponge pg_dump_2.dump touch -d "1 day ago" pg_dump_1.dump touch -d "2 days ago" pg_dump_2.dump touch -d "4 days ago" pg_dump_4.dump touch -d "5 days ago" pg_dump_5.dump cd .. || exit # Dump was corrupted before being compressed mkdir corrupted-compression cd corrupted-compression || exit cp ../../../../tests/data/pg_dump.dump pg_dump_1.dump cp ../../../../tests/data/pg_dump.dump pg_dump_2.dump tail -c +5 pg_dump_1.dump | sponge pg_dump_1.dump tail -c +5 pg_dump_2.dump | sponge pg_dump_2.dump gzip pg_dump_1.dump gzip pg_dump_2.dump cd .. || exit # Compressed dump was corrupted after compression mkdir compression-corrupted cd compression-corrupted || exit cp ../../../../tests/data/pg_dump.dump pg_dump_1.dump cp ../../../../tests/data/pg_dump.dump pg_dump_2.dump gzip pg_dump_1.dump gzip pg_dump_2.dump tail -c +5 pg_dump_1.dump.gz | sponge pg_dump_1.dump.gz tail -c +5 pg_dump_2.dump.gz | sponge pg_dump_2.dump.gz cd .. || exit