generated from NethServer/ns8-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts for restoring and dumping the piler database
- Loading branch information
Showing
4 changed files
with
79 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
set -e -o pipefail | ||
exec 1>&2 # Redirect any output to the journal (stderr) | ||
|
||
# Prepare an initialization script that restores the dump file | ||
mkdir -vp initdb.d | ||
mv -v piler.sql initdb.d | ||
#do the bash file to restore and exit once done | ||
cat - >initdb.d/zz_piler_restore.sh <<'EOS' | ||
# Print additional information: | ||
mysql --version | ||
# The script is sourced, override entrypoint args and exit: | ||
set -- true | ||
docker_temp_server_stop | ||
exit 0 | ||
EOS | ||
|
||
# once we exit we remove initdb.d | ||
trap 'rm -rfv initdb.d/' EXIT | ||
|
||
# we start a container to initiate a database and load the dump | ||
# at the end of piler_restore.sh the dump is loaded and | ||
# we exit the container | ||
podman run \ | ||
--rm \ | ||
--interactive \ | ||
--network=none \ | ||
--volume=./initdb.d:/docker-entrypoint-initdb.d:z \ | ||
--volume mysql-data:/var/lib/mysql/:Z \ | ||
--env MARIADB_ROOT_PASSWORD=Nethesis,1234 \ | ||
--env MARIADB_DATABASE=piler \ | ||
--env MARIADB_USER=piler \ | ||
--env MARIADB_PASSWORD=piler \ | ||
--replace --name=restore_db \ | ||
${MARIADB_IMAGE} |
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,8 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
rm -vf piler.sql |
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,21 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
set -e | ||
|
||
if ! systemctl --user -q is-active piler.service; then | ||
exit 0 | ||
fi | ||
|
||
podman exec mariadb-app mysqldump \ | ||
--databases piler \ | ||
--default-character-set=utf8mb4 \ | ||
--skip-dump-date \ | ||
--ignore-table=mysql.event \ | ||
--single-transaction \ | ||
--quick \ | ||
--add-drop-table > piler.sql |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
# | ||
# SOGo state/backup include patterns for Restic | ||
# Syntax reference: https://pkg.go.dev/path/filepath#Glob | ||
# Restic --files-from: https://restic.readthedocs.io/en/stable/040_backup.html#including-files | ||
# | ||
state/piler.sql | ||
volumes/mysql-conf.d | ||
volumes/mysql-data | ||
volumes/piler_var | ||
volumes/piler_manticore | ||
volumes/piler_store | ||
volumes/piler_etc |