Skip to content
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 1 commit into from
Oct 12, 2023

Conversation

thoomasbro
Copy link
Collaborator

No description provided.

Copy link
Member

@ivangabriele ivangabriele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S'il n'y a pas de soucis d'ordre / de conflit des commandes SQL exportées, c'est parfait comme ça.

Sinon je crois qu'on peut aussi passer par une stratégie pure docker où l'on copie le volume et le restore ensuite (j'ai vu un post là-dessus il y a un moment).


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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonne idée de linker le dossier des dumps via un volume ^^.


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}"
Copy link
Member

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.

Copy link
Collaborator Author

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.

@thoomasbro thoomasbro merged commit 60b08a4 into main Oct 12, 2023
10 checks passed
@thoomasbro thoomasbro deleted the thomas/add-restore-db-command branch October 12, 2023 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants