Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
WD=/opt/mariadb
mkdir -p $WD/{data,conf,backups}
cd $WD/backups
systemctl stop mariadb
No Format
#Backup via File-Level-Archive
systemctl stop mariadb
tar -zcvf mariadb-data-dir_"$(date '+%F')".tgz '/var/lib/mysql/'
tar -zcvf mariadb-conf-dir_"$(date '+%F')".tgz '/etc/mysql/'
No Format
#Copy Conf via RSync
rsync -avzP /etc/mysql/ $WD/conf/

...

No Format
cd $WD/backups
systemctl stopstart mariadb
cat << 'EOF' >mysql_all_db_dump.sh
#!/bin/bash
#https://dba.stackexchange.com/a/69667/113202
MYSQL_USER=root
MYSQL_PASS=rootpassword
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
#
# Collect all database names except for
# mysql, information_schema, and performance_schema
#
SQL="SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN"
SQL="${SQL} ('mysql','information_schema','performance_schema')"

DBLISTFILE=/tmp/DatabasesToDump.txt
mysql ${MYSQL_CONN} -ANe"${SQL}" > ${DBLISTFILE}

DBLIST=""
for DB in `cat ${DBLISTFILE}` ; do DBLIST="${DBLIST} ${DB}" ; done

MYSQLDUMP_OPTIONS="--routines --triggers --single-transaction"
mysqldump ${MYSQL_CONN} ${MYSQLDUMP_OPTIONS} --databases ${DBLIST} > mariadb_alldb_"$(date '+%F')".sql
EOF
chmod +x mysql_all_db_dump.sh
./mysql_all_db_dump.sh

...

No Format
UPDATE IGNORE mysql.user SET host = '192.168.1.%' WHERE host = 'localhost';

...