Backup & Export MySQL servers

This chapter presents the following DMK-MySQL backup scripts: MySQL backup “mbackup.sh”. And MySQL dump “mdump.sh”

The “mdump.sh” wrapper script for MySQL dumps is launched with following option to ensure all the database are backed up in the textual backup:

-all-databases --lock-all-tables --flush-logs --master-data=2 --routines

The executions of “mdump.sh” or “mbackup.sh” requires a configuration file, which contains the following parameters.

The script requires command lines argument in addition to the configuration file. Some of the configuration file parameters are also available in command-line. The parameters given in command line are from higher priority compared to their configuration values. Which allow different behave using the same configuration file.

Example:

mdump.sh –s ${MYSQL_SERVER}
mbackup.sh –s ${MYSQL_SERVER}

Parameters

A hyphen character prefixes the command line parameters as they are be used within a shell.

–h or –help

Display the Synopsis.

–s or -–sid

The target database on which, the MySQL dump or backup operation should be launched. This parameter is always required.

{mdump|mbackup}.sh –s ${MYSQL_SERVER}

–c or –-configfile

ℹ️The dbi services best practice consist of saving the configuration file under the database admin directory which makes the command-line parameter “ConfigFile” useless

cp ${DMK_HOME}/templates/{mdump|mbackup}.cfg \\ 
${DMK_MYSQL_ADMIN}/etc/{mdump|mbackup}.cfg

Otherwise the command-line parameter becomes mandatory

{mdump|mbackup}.sh –s ${MSQL_SERVER} –c <path to the configuration file>

–d or –-databasename

Optional parameter if you want to backup only one specific database.

{mdump|mbackup}.sh –s ${MSQL_SERVER} –d <database_name>

a or --alldatabasessinglefiles

Optional parameter if you want to have a separated backup file per database.

{mdump|mbackup}.sh –s ${MSQL_SERVER} –a

BckPath or DumpPath

ℹ️ The DumpPath parameter belongs to the MySQL dump script “mdump.sh”

#*************************************************************
# DumpPath
# MySQL dump destination
# Default is : "" - $DMK_MYSQL_ADMIN/backup
DumpPath=""

ℹ️ The bckPath parameter belongs to the MySQL backup script “mbackup.sh”. This script creates automatically a sub-folder for each execution (the folder name contains the start data of the backup)

#*************************************************************
# BckPath
# MySQL backup destination
# Default is : "" - $DMK_MYSQL_ADMIN/backup
BckPath=""

⚠️ If the backup or dump directory doesn’t exist, the MySQL operation will abort!

LogPath

#*************************************************************
# LogPath
# Destination of the log files
# Default is : "" - $DMK_MYSQL_ADMIN/log
LogPath=""

Compress

ℹ️ The compress option is only available for the MySQL dump script “mdump.sh”

#*************************************************************
# Commandline : --compress or -z
# Compression using
# Default is : "0" - non compressed
Compress=""

PreScript

#*************************************************************
# Launch a pre Export script
# the logfile is written under log_path
# Default is : ""
PreScript=""

PostScript

#*************************************************************
# Launch a post Export script
# the logfile is written under log_path
# Default is : ""
PostScript=""

Customer

#*************************************************************
# Name/ShortName of the customer
# Default is : "dbi-services"
Customer=""

NoSuccessMail

#*************************************************************
# NoSuccessMail
# Default is : "0" -means the sucessmail will be sent
NoSuccessMail="0"

MailRecipients

#*************************************************************
# MailRecipients
# comma separated list of mail recipients
# Default is : "" - empty
MailRecipients="”

SmtpServer

#*************************************************************
# SmtpServer
# Infrastructure SMTP server
# Default is : "" - localhost
SmtpServer=""

MailFrom

#*************************************************************
# MailFrom
# Hardcode address From sender
# Default is : "" - ${USERNAME}.${HOSTNAME}@${DOMAIN}
MailFrom=""

Last updated