mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-12 07:00:04 +03:00
scripts/mysql dumps: Add data dump script
This commit is contained in:
parent
f02efdd98b
commit
88e199e94e
53
scripts/eddn-dump-db-data
Executable file
53
scripts/eddn-dump-db-data
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
# Add ' -x' above to debug
|
||||
#
|
||||
# Produce a dump of the eddn database data
|
||||
|
||||
###########################################################################
|
||||
# Exit codes
|
||||
###########################################################################
|
||||
EXIT_CONFIG_MISSING=1
|
||||
EXIT_CL_ARGS=3
|
||||
###########################################################################
|
||||
|
||||
###########################################################################
|
||||
# Functions
|
||||
###########################################################################
|
||||
##################################################
|
||||
# Print usage information
|
||||
##################################################
|
||||
usage() {
|
||||
echo "Usage: $(basename $0) ( live | beta | dev )" >&2
|
||||
}
|
||||
##################################################
|
||||
###########################################################################
|
||||
|
||||
if [ -z "${1}" ];
|
||||
then
|
||||
usage
|
||||
echo "No EDDN environment specified." >&2
|
||||
exit ${EXIT_CL_ARGS}
|
||||
fi
|
||||
EDDN_ENV="${1}"
|
||||
|
||||
# Bring in some common configuration
|
||||
if [ ! -f "${HOME}/.local/bin/eddn_${EDDN_ENV}_config" ];
|
||||
then
|
||||
echo "eddn_${EDDN_ENV}_config is missing from $(pwd)" >&2
|
||||
exit ${EXIT_CONFIG_MISSING}
|
||||
fi
|
||||
. "${HOME}/.local/bin/eddn_${EDDN_ENV}_config"
|
||||
|
||||
|
||||
EDDN_HOME="${HOME}/${EDDN_ENV}"
|
||||
BACKUPS_DIR="${EDDN_HOME}/backups"
|
||||
|
||||
mkdir -p ${BACKUPS_DIR} || exit 1
|
||||
|
||||
DATETIME=$(date --iso-8601=seconds)
|
||||
|
||||
# This relies on ~/.my.cnf containing the password
|
||||
mysqldump -u eddn --skip-lock-tables --single-transaction --databases eddn_${EDDN_ENV} | nice gzip -9 -c - > "${BACKUPS_DIR}/eddn_${EDDN_ENV}-data-${DATETIME}.sql.gz"
|
||||
|
||||
# vim: tabstop=2 shiftwidth=2 textwidth=0 wrapmargin=0 expandtab
|
||||
|
@ -46,7 +46,7 @@ mkdir -p ${BACKUPS_DIR} || exit 1
|
||||
|
||||
DATETIME=$(date --iso-8601=seconds)
|
||||
|
||||
# This relies on ~root/.my.cnf containing the password
|
||||
# This relies on ~/.my.cnf containing the password
|
||||
mysqldump -u eddn --no-data --skip-lock-tables --databases eddn_${EDDN_ENV} > "${BACKUPS_DIR}/schema-${EDDN_ENV}-${DATETIME}.sql"
|
||||
|
||||
# vim: tabstop=2 shiftwidth=2 textwidth=0 wrapmargin=0 expandtab
|
||||
|
Loading…
x
Reference in New Issue
Block a user