mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-18 13:44:20 +01:00
Add lock capabilities during snapshot (#2063)
* Add service which locks database tables Add an additional service which helds a lock on all database tables. This allows to safely snapshot the database files. * Lock database during snapshot operation Fixes: #1353 * Update config.json * Update CHANGELOG.md Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
0
mariadb/rootfs/etc/services.d/mariadb-lock/down
Normal file
0
mariadb/rootfs/etc/services.d/mariadb-lock/down
Normal file
0
mariadb/rootfs/etc/services.d/mariadb-lock/finish
Normal file
0
mariadb/rootfs/etc/services.d/mariadb-lock/finish
Normal file
@@ -0,0 +1 @@
|
||||
3
|
||||
28
mariadb/rootfs/etc/services.d/mariadb-lock/run
Executable file
28
mariadb/rootfs/etc/services.d/mariadb-lock/run
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Start MariaDB client to lock tables (for snapshots)
|
||||
# ==============================================================================
|
||||
|
||||
bashio::log.info "Lock tables using mariadb client..."
|
||||
|
||||
exec 4> >(mariadb)
|
||||
MARIADB_PID=$!
|
||||
|
||||
echo "FLUSH TABLES WITH READ LOCK;" >&4
|
||||
|
||||
# Notify s6 about successful service start
|
||||
echo "" >&3
|
||||
|
||||
bashio::log.info "MariaDB tables locked."
|
||||
|
||||
# Register stop
|
||||
function stop_mariadb_client() {
|
||||
echo "UNLOCK TABLES;" >&4
|
||||
bashio::log.info "MariaDB tables unlocked."
|
||||
exec 4>&-
|
||||
# Successful exit, avoid wait exit status to propagate
|
||||
exit 0
|
||||
}
|
||||
trap "stop_mariadb_client" SIGTERM SIGHUP
|
||||
|
||||
wait "${MARIADB_PID}"
|
||||
Reference in New Issue
Block a user