-
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.
[Tech] Ajout de scripts de restauration de base de données (#3098)
## Linked issues None ---- - [ ] Tests E2E (Cypress) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced data management and security with automated database backup and restoration capabilities. - **Chores** - Updated `.gitignore` to exclude backup directories, ensuring sensitive data is not accidentally committed. - **Documentation** - Added Makefile targets `backup-db`, `restore-db`, and `dev-restore-db` for database backup and restoration scripts. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
8 changed files
with
373 additions
and
8 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
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,53 @@ | ||
name: "Build Application Docker Image" | ||
description: "Build application Docker image." | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set version and environment profile | ||
uses: ./.github/actions/set-version-and-environment-profile | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@master | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache-app | ||
key: ${{ runner.os }}-app | ||
restore-keys: | | ||
${{ runner.os }}-app | ||
- name: Build image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
load: true | ||
builder: ${{ steps.buildx.outputs.name }} | ||
file: infra/docker/app/Dockerfile | ||
push: false | ||
tags: monitorfish-app:${{ env.VERSION }} | ||
cache-from: type=local,src=/tmp/.buildx-cache-app | ||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-app-new | ||
build-args: | | ||
IS_RELEASE=false | ||
VERSION=${{ env.VERSION }} | ||
ENV_PROFILE=${{ env.ENV_PROFILE }} | ||
GITHUB_SHA=${{ github.sha }} | ||
SENTRY_URL=${{ secrets.SENTRY_URL }} | ||
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} | ||
SENTRY_ORG=${{ secrets.SENTRY_ORG }} | ||
SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }} | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
- name: Move cache | ||
shell: bash | ||
run: | | ||
rm -rf /tmp/.buildx-cache-app | ||
mv /tmp/.buildx-cache-app-new /tmp/.buildx-cache-app |
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,66 @@ | ||
name: Database Healthcheck | ||
|
||
on: | ||
schedule: | ||
# Every day at 7am UTC | ||
- cron: "0 7 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
backup_and_restore_database: | ||
name: Backup and restore database | ||
runs-on: ubuntu-latest | ||
env: | ||
MONITORFISH_BACKUPS_FOLDER: /opt/monitorfish_backups | ||
MONITORFISH_GEOSERVER_REMOTE_URL: "" | ||
MONITORFISH_GEOSERVER_LOCAL_URL: "" | ||
MONITORFISH_MONITORENV_PUBLIC_URL: "" | ||
MONITORFISH_MONITORENV_URL: "" | ||
MONITORFISH_MAPBOX_KEY: "" | ||
MONITORFISH_SHOM_KEY: "" | ||
MONITORFISH_OIDC_ENABLED: "" | ||
MONITORFISH_OIDC_REDIRECT_URI: "" | ||
MONITORFISH_OIDC_AUTHORITY: "" | ||
MONITORFISH_OIDC_CLIENT: "" | ||
MONITORFISH_API_PROTECTED_API_KEY: ${{ secrets.MONITORFISH_API_KEY }} | ||
MONITORFISH_API_PROTECTED_PATHS: "" | ||
MONITORFISH_API_PROTECTED_PUBLIC_PATHS: "" | ||
MONITORFISH_SENTRY_ENV: "prod" | ||
MONITORFISH_SENTRY_DSN: "" | ||
MONITORFISH_SENTRY_TRACING_ORIGINS: "" | ||
# MONITORFISH_VERSION: "0.0.0" | ||
MONITORFISH_MISSION_FORM_AUTO_SAVE_ENABLED: "true" | ||
MONITORFISH_MISSION_FORM_AUTO_UPDATE_ENABLED: "true" | ||
MONITORFISH_PRIOR_NOTIFICATION_LIST_ENABLED: "true" | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get last release version | ||
id: get-last-release-version | ||
uses: pozetroninc/github-action-get-latest-release@master | ||
with: | ||
repository: mtes-mct/monitorfish | ||
|
||
- name: Set `MONITORFISH_VERSION` & `VERSION` env vars to the latest release version | ||
run: | | ||
echo "MONITORFISH_VERSION=${{ steps.get-last-release-version.outputs.release }}" >> $GITHUB_ENV | ||
# echo "VERSION=${{ steps.get-last-release-version.outputs.release }}" >> $GITHUB_ENV | ||
- name: Pull and run application | ||
run: | | ||
# docker compose up -d --quiet-pull --build db | ||
make restart-remote-app | ||
working-directory: ./infra/remote | ||
|
||
- name: Backup database | ||
run: | | ||
echo "MONITORFISH_BACKUPS_FOLDER=${MONITORFISH_BACKUPS_FOLDER}" >> ~/.monitorfish | ||
cp ./infra/remote/backup/pg_backup.config.template ./infra/remote/backup/pg_backup.config | ||
make db-backup | ||
- name: Restore database | ||
run: | | ||
make db-restore TAG="$(date +"%Y-%m-%d")-daily" |
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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
################################################################################ | ||
# POSTGRESQL BACKUP & RESTORE CONFIG FOR DEV ENVIRONMENT | ||
|
||
HOSTNAME=0.0.0.0 | ||
USERNAME=postgres | ||
BACKUP_DIR=./.backups/ |
Oops, something went wrong.