#!/bin/bash # **************************************************************************************************** # * ______ _ _ * # * | ____| /\ (_) | | * # * | |__ _ _ _ __ ___ _ __ ___ __ _ _ __ / \ _ _ __ _ __ ___ _ __| |_ ___ * # * | __|| | | | '__/ _ \| '_ \ / _ \/ _` | '_ \ / /\ \ | | '__| '_ \ / _ \| '__| __/ __| * # * | |___| |_| | | | (_) | |_) | __/ (_| | | | | / ____ \| | | | |_) | (_) | | | |_\__ \ * # * |______\__,_|_| \___/| .__/ \___|\__,_|_| |_| /_/ \_\_|_| | .__/ \___/|_| \__|___/ * # * | | | | * # * |_| |_| * # * * # **************************************************************************************************** # This file is part of the European Airports Project, a free, collaborative platform of airport data # extending beyond the official AIPs. # Copyright (C) 2023 # Florian Meissner # This program 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 (at your option) any later version. This program 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 this program. # (license.md in the root folder of this project) If not, see . # **************************************************************************************** # * ,__ __ ____ , __ ____ * # * /| | | o (| \/|/ \ (| \ * # * | | | __, ,_ __, | || __/ | | _ _ _ _ * # * | | | / | / | | / | _| || \ _| || | / |/ |/ | |/ \_ * # * | | |_/\_/|_/ |_/|_/\_/|_/(/\___/ |(__/ (/\___/ \_/|_/ | | |_/|__/ * # * /| * # * \| * # **************************************************************************************** # Dump database contents to be later backed up. The dump will not contain any DROP or CREATE # statements in order not to damage any existing data. This way `dbImport.sh` can use these files # and run them over an eventually existing DB during the Docker entryint script. DUMP_DIR="/tmp/mariadb-dump" DB_USER=`cat /run/secrets/rootUser` DB_PW=`cat /run/secrets/rootPw` DB_NAMES=( #"example-db" "eaMain" ) ERROR_LOG="/var/log/mysql/dump.log" # Set excluded database tables here. Use an index for each database and separate tables by spaces. declare -A EXCLUDED_TABLES=( #[example-db]="table1 table2 table3" #[toplist]="cty" ) ################################################################################################### mkdir -p $DUMP_DIR for db in ${DB_NAMES[@]}; do # Assemble base command read -r -d '' cmd << EOF mariadb-dump --single-transaction --no-create-db --insert-ignore --user=$DB_USER --password=$DB_PW --databases $db --dump-date --log-error=$ERROR_LOG --skip-add-drop-table --skip-extended-insert --no-create-info EOF # Append excluded tables for tbl in ${EXCLUDED_TABLES[$db]}; do cmd="${cmd} --ignore-table=${db}.${tbl}" done $cmd > $DUMP_DIR/$db.sql done