-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tech - commande de restauration de la db en dev #876
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
services: | ||
db: | ||
volumes: | ||
- "../../.backups/:/opt/monitorenv_backups" | ||
geoserver: | ||
restart: unless-stopped | ||
links: | ||
|
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
BACKUP_FILE_PATH="./.backups/$(date '+%Y-%m-%d').sqlc" | ||
BACKUP_FILE_PATH="./.backups/$(date '+%Y-%m-%d').sql" | ||
|
||
if [ ! -d ./.backups ]; then | ||
echo "Creating directory './.backups'…" | ||
mkdir ./.backups | ||
fi | ||
|
||
echo "Dumping databases in '${BACKUP_FILE_PATH}'…" | ||
docker exec -t monitorenv-db-1 pg_dump -c -F c -U postgres monitorenvdb > "${BACKUP_FILE_PATH}" | ||
docker exec -t monitorenv-db-1 pg_dump -c -F p -U postgres monitorenvdb > "${BACKUP_FILE_PATH}" | ||
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 |
---|---|---|
|
@@ -4,26 +4,6 @@ set -e | |
LAST_BACKUP_FILE_NAME=$(ls -p ./.backups | grep -v / | sort -V | tail -n 1) | ||
LAST_BACKUP_FILE_PATH="./.backups/${LAST_BACKUP_FILE_NAME}" | ||
|
||
# echo "Stopping and removing database container with its volume…" | ||
# docker compose \ | ||
# --project-name monitorenv \ | ||
# --project-directory ./infra/docker \ | ||
# --env-file='./infra/.env' \ | ||
# -f ./infra/docker/docker-compose.yml \ | ||
# -f ./infra/docker/docker-compose.dev.yml \ | ||
# rm -f -s -v db | ||
|
||
# echo "Starting databse container…" | ||
# docker compose \ | ||
# --project-name monitorenv \ | ||
# --project-directory ./infra/docker \ | ||
# --env-file='./infra/.env' \ | ||
# -f ./infra/docker/docker-compose.yml \ | ||
# -f ./infra/docker/docker-compose.dev.yml \ | ||
# up --wait db | ||
|
||
# # echo "Waiting for database to be ready…" | ||
# timeout 90s bash -c "until docker exec monitorenv-db-1 pg_isready ; do sleep 1 ; done" | ||
|
||
echo "Restoring backup '${LAST_BACKUP_FILE_PATH}'…" | ||
cat "${LAST_BACKUP_FILE_PATH}" | docker exec -t monitorenv-db-1 pg_restore -c -d monitorenvdb -F c -U postgres | ||
docker exec -t monitorenv-db-1 psql -d monitorenvdb -U postgres -f "/opt/monitorenv_backups/${LAST_BACKUP_FILE_NAME}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bonne idée de linker le dossier des dumps via un volume ^^. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu n'as pas de soucis d'ordre des requêtes SQL qui sont dumpées lorsqu'elles sont restorées ? J'avais utilisé le format
c
en espérant que ça évite le problème mais sans succès.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non j'ai pas l'impression. Avec l'option
--clean
l'ajout des contraintes se fait à la fin et ça semble bien se passer.