Skip to content

Commit

Permalink
MariaDB: Use proper log redirection during backup (#3029)
Browse files Browse the repository at this point in the history
* Use proper log redirection during backup

* make lint happy

* move backup commands to script

* use exec, we are already using a shell

* Apply suggestions from code review

Co-authored-by: Stefan Agner <stefan@agner.ch>
  • Loading branch information
lmagyar and agners committed May 8, 2023
1 parent 7656175 commit 6a17fbf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
4 changes: 4 additions & 0 deletions mariadb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.6.1

- Use proper log redirection during backup

## 2.6.0

- Migrate add-on layout to S6 Overlay
Expand Down
6 changes: 3 additions & 3 deletions mariadb/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 2.6.0
version: 2.6.1
slug: mariadb
name: MariaDB
description: A SQL database server
Expand All @@ -10,8 +10,8 @@ arch:
- aarch64
- amd64
- i386
backup_post: /command/s6-rc -d change mariadb-lock
backup_pre: /command/s6-rc -u change mariadb-lock
backup_post: unlock-tables-for-backup
backup_pre: lock-tables-for-backup
image: homeassistant/{arch}-addon-mariadb
init: false
options:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
# Unlock tables locked for backups
# ==============================================================================

# Due to it is started by the supervisor calling the backup_post: `/command/s6-rc -d change mariadb-lock` command,
# it's stdout won't be redirected automatically to the add-on's log
exec &> /proc/1/fd/1

declare MARIADB_LOCK_CORE_PID
MARIADB_LOCK_CORE_PID=$(s6-svstat -o pid "/run/service/mariadb-lock-core")
if bashio::var.equals ${MARIADB_LOCK_CORE_PID} -1; then
Expand Down
4 changes: 0 additions & 4 deletions mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-lock-post/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
# Lock tables for backups
# ==============================================================================

# Due to it is started by the supervisor calling the backup_pre: `/command/s6-rc -u change mariadb-lock` command,
# it's stdout won't be redirected automatically to the add-on's log
exec &> /proc/1/fd/1

declare MARIADB_LOCK_CORE_PID
MARIADB_LOCK_CORE_PID=$(s6-svstat -o pid "/run/service/mariadb-lock-core")
if bashio::var.equals ${MARIADB_LOCK_CORE_PID} -1; then
Expand Down
9 changes: 9 additions & 0 deletions mariadb/rootfs/usr/bin/lock-tables-for-backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Lock tables for backup
# ==============================================================================

# Redirect stdout to the add-on's log
exec &> /proc/1/fd/1
exec s6-rc -v 2 -u change mariadb-lock
9 changes: 9 additions & 0 deletions mariadb/rootfs/usr/bin/unlock-tables-for-backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Unlock tables for backup
# ==============================================================================

# Redirect stdout to the add-on's log
exec &> /proc/1/fd/1
exec s6-rc -v 2 -d change mariadb-lock

0 comments on commit 6a17fbf

Please sign in to comment.