Skip to content

Commit

Permalink
Merge pull request #131 from fradelg/bugfix/skip-dump-date
Browse files Browse the repository at this point in the history
Fixed database name on dumps
  • Loading branch information
fradelg authored Dec 9, 2024
2 parents cff595e + 1d3c439 commit 4bacd0d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
22 changes: 1 addition & 21 deletions .github/workflows/image.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@

name: build docker image

on:
workflow_dispatch:
push:
branches:
- "**"
tags:
- "**"

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Test Bash scripts
run: sudo apt-get -qq update && sudo apt-get install -y devscripts shellcheck && make test
- name: Test image
env:
VOLUME_PATH: /tmp/mariadb
DATABASE_NAME: foo
MARIADB_ROOT_PASSWORD: abcd
run: |
docker compose up -d mariadb
docker compose run backup /backup.sh
docker compose run backup /restore.sh /backup/latest.foo.sql.gz
docker compose stop
build:
runs-on: ubuntu-22.04
needs: test
steps:
- name: Checkout the code
uses: actions/checkout@v4
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build docker image

on:
workflow_dispatch:
push:
branches:
- "**"

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Test Bash scripts
run: sudo apt-get -qq update && sudo apt-get install -y devscripts shellcheck && make test
- name: Test image
env:
VOLUME_PATH: /tmp/mariadb
DATABASE_NAME: foo
MARIADB_ROOT_PASSWORD: abcd
run: |
docker compose up -d mariadb
docker compose run backup /backup.sh
docker compose run backup /restore.sh /backup/latest.foo.sql.gz
docker compose stop
5 changes: 2 additions & 3 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ do
BASIC_OPTS="--single-transaction"
if [ -n "$REMOVE_DUPLICATES" ]
then
echo "WARNING: disabling comments in backup to remove deuplicate backups. Automatic database name detection won't work so set MYSQL_DATABASE on restore"
BASIC_OPTS="$BASIC_OPTS" --skip-comments
BASIC_OPTS="$BASIC_OPTS --skip-dump-date"
fi
if mysqldump $BASIC_OPTS $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME"
then
Expand All @@ -52,7 +51,7 @@ do
cd /backup || exit && ln -s "$BASENAME" "$(basename "$LATEST")"
if [ -n "$REMOVE_DUPLICATES" ]
then
echo "=> Removing duplicate database dumps"
echo "==> Removing duplicate database dumps"
fdupes -idN /backup/
fi
if [ -n "$MAX_BACKUPS" ]
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ services:
environment:
- MYSQL_HOST=my_mariadb
- MYSQL_USER=root
- MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_PASS=${MARIADB_ROOT_PASSWORD}
- MAX_BACKUPS=1
- INIT_BACKUP=1
Expand Down

0 comments on commit 4bacd0d

Please sign in to comment.