1
0
Fork 0
medicine-config/cron-tasks/backup_database_medicine.sh

20 lines
500 B
Bash
Executable File

#!/bin/sh
set -e
export LC_ALL=C
cd /root/medicine-backups/
weekday=$(date +%a)
backup_filename="medicine_${weekday}.sql"
archive_filename="medicine_${weekday}.tar.gz"
docker exec -i medicine-stack-postgres pg_dump --no-owner -U postgres -F p medicine > "${backup_filename}" \
--exclude-table-data=riisz_logging \
--exclude-table-data=reversion_*
if test -f "${archive_filename}"; then
rm "${archive_filename}"
fi
tar -czf "${archive_filename}" "${backup_filename}"
rm "${backup_filename}"