1
0
Fork 0
This commit is contained in:
Ilya Mukhortov 2024-03-24 21:55:04 +10:00
parent de83fe39a1
commit 55fb2e2877
3 changed files with 40 additions and 3 deletions

View File

@ -48,8 +48,7 @@
30 13 * * * /root/medicine-config/medicine-remd/update.sh 30 13 * * * /root/medicine-config/medicine-remd/update.sh
50 13 * * * /root/medicine-config/cron-tasks/backup_database_medicine_remd.sh 50 13 * * * /root/medicine-config/medicine-remd/backup_database.sh
20 13 * * * /root/medicine-config/medicine/update.sh 20 13 * * * /root/medicine-config/medicine/update.sh
55 13 * * * /root/medicine-config/medicine/backup_database.sh
55 13 * * * /root/medicine-config/cron-tasks/backup_database_medicine.sh

View File

@ -0,0 +1,18 @@
#!/bin/sh
set -e
export LC_ALL=C
cd /root/medicine-backups/
weekday_number=$(date +%u)
weekday=$(date +%A | tr '[:upper:]' '[:lower:]')
backup_filename="medicine_remd_${weekday_number}_${weekday}.sql"
archive_filename="medicine_remd_${weekday_number}_${weekday}.tar.gz"
docker exec -i medicine-stack-postgres pg_dump --no-owner -U postgres -F p medicine_remd > "${backup_filename}"
if test -f "${archive_filename}"; then
rm "${archive_filename}"
fi
tar -czf "${archive_filename}" "${backup_filename}"
rm "${backup_filename}"

20
medicine/backup_database.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
set -e
export LC_ALL=C
cd /root/medicine-backups/
weekday_number=$(date +%u)
weekday=$(date +%A | tr '[:upper:]' '[:lower:]')
backup_filename="medicine_${weekday_number}_${weekday}.sql"
archive_filename="medicine_${weekday_number}_${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}"