-
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.
Implement database dump and restore, and start service
- Loading branch information
1 parent
2b21a7c
commit 3323d86
Showing
6 changed files
with
77 additions
and
6 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
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) 2022 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 erpnext.sql initdb.d | ||
#do the bash file to restore and exit once done | ||
cat - >initdb.d/zz_erpnext_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 erpnext_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=erpnext \ | ||
--env MARIADB_USER=erpnext \ | ||
--env MARIADB_PASSWORD=erpnext \ | ||
--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
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) 2022 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
rm -vf erpnext.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) 2022 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
set -e | ||
|
||
if ! systemctl --user -q is-active erpnext.service; then | ||
exit 0 | ||
fi | ||
|
||
podman exec mariadb-app mysqldump \ | ||
--databases erpnext \ | ||
--default-character-set=utf8mb4 \ | ||
--skip-dump-date \ | ||
--ignore-table=mysql.event \ | ||
--single-transaction \ | ||
--quick \ | ||
--add-drop-table > erpnext.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