#!/usr/bin/env bash

if [ -z "$1" ]; then
  echo "usage: $0 <database>" 1>2&
  exit 1
fi

if [ "$EUID" -ne "0" ]; then
  echo "This script must be run as root." 1>2&
  exit 2
fi

DATABASE="$1"
DUMP_FILE="<%= @backup_dir %>/$DATABASE.sql.gz"
MYSQL_CREDENTIALS="--defaults-file=<%= @backup_mysql_config %>"
MYSQL_OPTS="--skip-opt --add-drop-table --create-options --disable-keys --comments \
            --quick --set-charset --no-create-db --default-character-set=utf8 \
            --compress --ignore-table=mysql.event"

ps cax | grep mysqld > /dev/null
if [ $? -eq 0 ]; then
  mysqldump $MYSQL_CREDENTIALS $MYSQL_OPTS --databases "$DATABASE" | gzip > "$DUMP_FILE"
  chmod go-rwx "$DUMP_FILE"
fi

#!/usr/bin/env bash

if [ -z "$1" ]; then
  echo "usage: $0 <database>" 1>2&
  exit 1
fi

if [ "$EUID" -ne "0" ]; then
  echo "This script must be run as root." 1>2&
  exit 2
fi

DATABASE="$1"
DUMP_FILE="<%= @backup_dir %>/$DATABASE.sql.gz"
MYSQL_CREDENTIALS="--defaults-file=<%= @option_file %>"
MYSQL_OPTS="--skip-opt --add-drop-table --create-options --disable-keys --comments \
            --quick --set-charset --no-create-db --default-character-set=utf8 \
            --compress --ignore-table=mysql.event"

ps cax | grep mysqld > /dev/null
if [ $? -eq 0 ]; then
  mysqldump $MYSQL_CREDENTIALS $MYSQL_OPTS --databases "$DATABASE" | gzip > "$DUMP_FILE"
  chmod go-rwx "$DUMP_FILE"
fi

Fix broken MySQL option file
Fix broken MySQL option file
