Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienheureux committed Jul 10, 2024
1 parent 6cf3d1c commit dd328d3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/sync_databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
DUPLICATE_SOURCE_APP: ${{ secrets.DUPLICATE_SOURCE_APP }}
DUPLICATE_ADDON_KIND: postgresql
PREPROD_DATABASE_URL: ${{ secrets.PREPROD_DATABASE_URL }}
RUN: scalingo --app "${DUPLICATE_SOURCE_APP}" run

defaults:
run:
Expand All @@ -26,23 +27,22 @@ jobs:
run: |
# Login to Scalingo, using the token stored in `DUPLICATE_API_TOKEN`:
scalingo login --api-token "${DUPLICATE_API_TOKEN}"
- name: Install Scalingo CLI
run: ${RUN} install-scalingo-cli
- name: Install postgres tools
run: ${RUN} dbclient-fetcher "${DUPLICATE_ADDON_KIND}"
- name: Generate database archive
run: |
archive_name="backup.tar.gz"
# Install additional tools to interact with the database:
scalingo --app "${DUPLICATE_SOURCE_APP}" run dbclient-fetcher "${DUPLICATE_ADDON_KIND}"
# Retrieve the addon id:
addon_id="$( scalingo --app "${DUPLICATE_SOURCE_APP}" addons \
| grep "${DUPLICATE_ADDON_KIND}" \
| cut -d "|" -f 3 \
| tr -d " " )"
# Download the latest backup available for the specified addon:
scalingo --app "${DUPLICATE_SOURCE_APP}" --addon "${addon_id}" \
${RUN} scalingo --app "${DUPLICATE_SOURCE_APP}" --addon "${addon_id}" \
backups-download --output "${archive_name}"
- name: Restore the database
run: |
# Get the name of the backup file:
Expand All @@ -51,8 +51,8 @@ jobs:
| cut -d "/" -f 2 )"
# Extract the archive containing the downloaded backup:
scalingo run --app "${DUPLICATE_SOURCE_APP}" tar --extract --verbose --file="${archive_name}" --directory="/app/"
tar --extract --verbose --file="${archive_name}" --directory="/app/"
# Restore the data:
scalingo run --app "${DUPLICATE_SOURCE_APP}" pg_restore --clean --if-exists --no-owner --no-privileges --no-comments \
pg_restore --clean --if-exists --no-owner --no-privileges --no-comments \
--dbname "${DATABASE_URL}" "/app/${backup_file_name}"

0 comments on commit dd328d3

Please sign in to comment.