#!/bin/bash
#
# Copyright (C) 2022 Nethesis S.r.l.
# http://www.nethesis.it - nethserver@nethesis.it
#
# 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

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/roundcubemail-mysql.sock \
    --databases roundcubemail --default-character-set=utf8mb4 \
    --skip-dump-date --ignore-table=mysql.event --single-transaction \
    --quick --add-drop-table \
    -r $backup_dir/roundcubemail.sql
