Changes between Initial Version and Version 1 of MysqlBackup


Ignore:
Timestamp:
03/04/16 12:45:48 (9 months ago)
Author:
chris
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MysqlBackup

    v1 v1  
     1Script created on ticket:907 and used on PuffinServer. 
     2 
     3{{{ 
     4#!/bin/bash 
     5 
     6# Directory for root to dump all database files  
     7DUMP_DIR="/var/backups/mysql/sqldump" 
     8 
     9if [[ ! -d "${DUMP_DIR}" ]]; then 
     10  mkdir "${DUMP_DIR}" -p 
     11  chmod 700 "${DUMP_DIR}" 
     12fi 
     13 
     14# All the MySQL databases, excluding ones we don't want  
     15DATABASES=$(mysql -NBA -e 'SHOW DATABASES' | grep -vw 'mysql' | grep -vw 'information_schema' | grep -vw 'performance_schema' ) 
     16 
     17# Loop through the databases and dump them 
     18for d in ${DATABASES} ; do 
     19  # Find the cache tables 
     20  CACHE_TABLES=$(mysql -NBA -e 'show tables' ${d} | egrep '^cach|flood|watchdog') 
     21  for c in ${CACHE_TABLES}; do 
     22    mysql -NBA -e "TRUNCATE ${c}" ${d} 
     23  done 
     24  # Dump the databases to DUMP_DIR 
     25  echo "Dumping ${d}" 
     26  nice -n19 mysqldump --add-drop-table ${d} > ${DUMP_DIR}/${d}.sql || exit 1 
     27done 
     28}}}