-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 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
36 changes: 36 additions & 0 deletions
36
root/etc/e-smith/events/actions/nethserver-nextcloud-rh-mariadb105-dump-database
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,36 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (C) 2021 Nethesis S.r.l. | ||
# http://www.nethesis.it - [email protected] | ||
# | ||
# This script is part of NethServer. | ||
# | ||
# NethServer is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, | ||
# or any later version. | ||
# | ||
# NethServer is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with NethServer. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
source /opt/rh/rh-mariadb105/enable | ||
PATH=$PATH:/opt/rh/rh-mariadb105/root/usr/bin/ | ||
|
||
umask 0027 | ||
backup_dir=/var/lib/nethserver/backup/rh-mariadb105/ | ||
|
||
if [ ! -d $backup_dir ]; then | ||
mkdir -p $backup_dir | ||
fi | ||
|
||
mysqldump --socket /run/rh-mariadb105-mariadb/nextcloud-mysql.sock \ | ||
--databases nextcloud --default-character-set=utf8mb4 \ | ||
--skip-dump-date --ignore-table=mysql.event --single-transaction \ | ||
--quick --add-drop-table \ | ||
-r $backup_dir/nextcloud.sql |
42 changes: 42 additions & 0 deletions
42
root/etc/e-smith/events/nethserver-nextcloud-restore-rh-mariadb105-database
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,42 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (C) 2021 Nethesis S.r.l. | ||
# http://www.nethesis.it - [email protected] | ||
# | ||
# This script is part of NethServer. | ||
# | ||
# NethServer is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, | ||
# or any later version. | ||
# | ||
# NethServer is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with NethServer. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
source /opt/rh/rh-mariadb105/enable | ||
PATH=$PATH:/opt/rh/rh-mariadb105/root/usr/bin/ | ||
|
||
if [[ ! -f '/var/lib/nethserver/backup/rh-mariadb105/nextcloud.sql' ]]; then | ||
echo "[ERROR] Error the nextcloud SCL mariadb105 dump does not exist" | ||
exit 1 | ||
fi | ||
|
||
password=`perl -e "use NethServer::Password; print NethServer::Password::store('nextcloud');"` | ||
mysql --socket=/run/rh-mariadb105-mariadb/nextcloud-mysql.sock -e "CREATE DATABASE IF NOT EXISTS nextcloud;" | ||
mysql --socket=/run/rh-mariadb105-mariadb/nextcloud-mysql.sock --database nextcloud < /var/lib/nethserver/backup/rh-mariadb105/nextcloud.sql | ||
mysql --socket=/run/rh-mariadb105-mariadb/nextcloud-mysql.sock -e "ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" | ||
mysql --socket=/run/rh-mariadb105-mariadb/nextcloud-mysql.sock -e "grant all on nextcloud.* to 'nextcloud'@'localhost' identified by '$password';" | ||
mysql --socket=/run/rh-mariadb105-mariadb/nextcloud-mysql.sock -e "FLUSH PRIVILEGES" | ||
|
||
if [[ $? -ne 0 ]]; then | ||
echo "[ERROR] Error while restoring nextcloud database to SCL mariadb105" | ||
exit 1 | ||
fi | ||
|
||
rm -f /var/lib/nethserver/backup/rh-mariadb105/nextcloud.sql |