-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
69 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ [email protected] | |
|
||
# répertoire de base pour les volumes des services (data + config) | ||
VOLUME_DATA_DIRECTORY=./data | ||
ASSETS_DIRECTORY=./assets | ||
|
||
# accès base de données | ||
POSTGRES_USER="geonatadmin" | ||
|
@@ -116,7 +117,8 @@ POSTGRES_IMAGE=postgis/postgis:15-3.3 | |
POSTGRES_CONTAINER_NAME=${CONTAINER_NAME_PREFIX}postgres | ||
POSTGRES_VOLUME_DATA_DIRECTORY=${VOLUME_DATA_STORAGE_DIRECTORY}/postgres | ||
POSTGRES_VOLUME_BACKUP_DIRECTORY=${VOLUME_DATA_SERVICES_DIRECTORY}/postgres/backup | ||
POSTGRES_VOLUME_INIT_DB_DIRECTORY="./assets/db" | ||
POSTGRES_VOLUME_SCRIPTS_DIRECTORY=${ASSETS_DIRECTORY}/postgres/scripts | ||
POSTGRES_VOLUME_INIT_DB_DIRECTORY=${ASSETS_DIRECTORY}/postgres/init_db | ||
POSTGRES_SHM_SIZE=1000000000 | ||
|
||
|
||
|
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 |
---|---|---|
|
@@ -23,6 +23,7 @@ [email protected] | |
|
||
# répertoire de base pour les volumes des services (data + config) | ||
VOLUME_DATA_DIRECTORY=./data | ||
ASSETS_DIRECTORY=./assets | ||
|
||
# accès base de données | ||
POSTGRES_USER="geonatadmin" | ||
|
@@ -117,7 +118,8 @@ POSTGRES_IMAGE=postgis/postgis:15-3.3 | |
POSTGRES_CONTAINER_NAME=${CONTAINER_NAME_PREFIX}postgres | ||
POSTGRES_VOLUME_DATA_DIRECTORY=${VOLUME_DATA_STORAGE_DIRECTORY}/postgres | ||
POSTGRES_VOLUME_BACKUP_DIRECTORY=${VOLUME_DATA_SERVICES_DIRECTORY}/postgres/backup | ||
POSTGRES_VOLUME_INIT_DB_DIRECTORY="./assets/db" | ||
POSTGRES_VOLUME_SCRIPTS_DIRECTORY=${ASSETS_DIRECTORY}/postgres/scripts | ||
POSTGRES_VOLUME_INIT_DB_DIRECTORY=${ASSETS_DIRECTORY}/postgres/init_db | ||
POSTGRES_SHM_SIZE=1000000000 | ||
|
||
|
||
|
File renamed without changes.
File renamed without changes.
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,61 @@ | ||
#!/bin/sh | ||
# | ||
# Crée un dump de la base geonature | ||
# Renseigne le fichier log avec la date de backup | ||
# et la taille du fichier non compressé | ||
|
||
echo "+-------------------------------+" | ||
echo "| Database backup |" | ||
echo "+-------------------------------+" | ||
|
||
# - 1 )logs (start) | ||
log_file_global=/backup/backup.log | ||
|
||
date_start=$(date '+%Y-%m-%d_%H-%M-%S') | ||
date_jour=$(date '+%Y-%m-%d') | ||
log_line_start="${date_start} -> ... (en cours)" | ||
echo $log_line_start >> $log_file_global | ||
|
||
|
||
# - 2 )creation du backup | ||
|
||
backup_file=/backup/geonature_backup.sql | ||
|
||
export PGPASSWORD=${POSTGRES_PASS} | ||
pg_dump --format=plain \ | ||
--create \ | ||
--no-owner --no-acl \ | ||
-d ${POSTGRES_DB} -h localhost -U ${POSTGRES_USER} \ | ||
> $backup_file | ||
|
||
# patch pour l'extension pg_trgm | ||
sed -i "s/with SCHEMA pg_catalog//" $backup_file | ||
|
||
|
||
# - compression du backup | ||
|
||
tar cvfz ${backup_file}_${date_jour}.tar.gz ${backup_file} | ||
|
||
# - on regarde la taille du backup non compressé (pour les logs) | ||
|
||
size_h_backup=$(ls -lh $backup_file | awk '{print $5}') | ||
size_backup=$(ls -l $backup_file | awk '{print $5}') | ||
|
||
# - suppression du fichier non compressé | ||
rm ${backup_file} | ||
|
||
# - 3) log (end) | ||
|
||
date_end=$(date '+%Y-%m-%d_%H-%M-%S') | ||
log_line_end="${date_start} -> ${date_end} : $size_h_backup ($size_backup)" | ||
sed -i "s/${log_line_start}.*/${log_line_end}/" $log_file_global | ||
tail -n 1 $log_file_global | ||
|
||
# rotation des fichiers | ||
# on garde les 5 derniers dumps ? | ||
files_to_remove=$(ls /backup/geonature_backup* | sort -r | awk 'NR > 5 { print $1}') | ||
|
||
if [ ! -z "${files_to_remove}" ]; then | ||
echo rm ${files_to_remove} | ||
rm ${files_to_remove} | ||
fi |
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