Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ian Eiloart
Sympl
Commits
825ef19c
Commit
825ef19c
authored
Jul 31, 2019
by
Paul Cammish
Browse files
Updated to use sympl config and permissions by default
parent
35e0af80
Changes
1
Hide whitespace changes
Inline
Side-by-side
mysql/bin/sympl-sqldump
View file @
825ef19c
...
...
@@ -123,7 +123,7 @@ CONFIG_FILE=/etc/sympl-sqldump.config
MYSQL
=
$(
which mysql 2> /dev/null
)
MYSQLDUMP
=
$(
which mysqldump 2> /dev/null
)
MYSQL_DEFAULTS
=
"
$HOME
/.my.cnf"
MYSQL_DEFAULTS
=
"
/home/sympl
/.my.cnf"
MYSQL_SKIP_DB
=
'information_schema performance_schema'
MYSQLDUMP_OPTIONS
=
'--create-options --no-create-db --events --triggers --routines --dump-date --tz-utc'
...
...
@@ -249,7 +249,7 @@ if [ "${#PARAMETERS}" -gt "0" ]; then
Common
--dir, -d <path> Override path to dump directory.
Will be created/chown'd/chmod'd to
root
user.
Will be created/chown'd/chmod'd to
sympl
user.
Defaults to
$DUMP_DIR
--keep, -k <number> Number of dumps to keep before removing old copies.
Defaults to
$KEEP_MAX_COPIES
...
...
@@ -263,17 +263,17 @@ Executable paths
Authentication
--mysql-defaults Optional 'defaults-file' to use in debian.cnf
format. Defaults to
~/.my.cnf,
format. Defaults to
$MYSQL_DEFAULTS
,
/etc/mysqldump/sympl-sqldump.cnf and
/etc/mysqldump/debian.cnf in that order.
Must be secured to root user only.
Must be secured to root
or sympl
user only.
Other
--force Force a run even if currently locked.
--config <file> Specify a config file to override defaults.
Defaults to /etc/sympl-sqldump.conf if exists
and must be secured to root.
and must be secured to root
user only
.
--help This text.
"
...
...
@@ -285,8 +285,8 @@ fi
#############################################################################
if
[
$(
id
-u
)
-ne
0
]
;
then
_
error This must be run as root
.
_
exit 256
e
cho
"E
rror
:
This must be run as root
"
exit
256
fi
...
...
@@ -345,15 +345,15 @@ fi
## MariaDB can simply be used with 'mysql', others will need
## $HOME/.my.cnf, /etc/mysql/sympl-sqldump.cnf or /etc/mysql/debian.cnf
## Use credentials from (in order) $HOME/.my.cnf, /etc/mysql/sympl-sqldump.cnf,
## Use credentials from (in order) $HOME/.my.cnf, /etc/mysql/sympl-sqldump.cnf,
## /etc/mysql/debian.cnf or the normal MySQL methods available to root.
# look for /etc/mysql directory (won't exist on centos)
if
[
-d
/etc/mysql
]
;
then
if
[
-f
"
$MYSQL_DEFAULTS
"
]
;
then
if
[
"
$(
find
"
$MYSQL_DEFAULTS
"
-user
$(
whoami
)
-perm
0600 |
wc
-l
)
"
==
"1"
]
;
then
_debug Secure
$
HOME
/.my.cnf
found.
AUTH
=
"--defaults-file=
$
HOME
/.my.cnf
"
if
[
"
$(
find
"
$MYSQL_DEFAULTS
"
-user
sympl
-perm
0600 |
wc
-l
)
"
==
"1"
]
;
then
_debug Secure
$
MYSQL_DEFAULTS
found.
AUTH
=
"--defaults-file=
$
MYSQL_DEFAULTS
"
fi
elif
[
-f
/etc/mysql/sympl-sqldump.cnf
]
;
then
if
[
"
$(
find /etc/mysql/sympl-sqldump.cnf
-user
root
-perm
0600 |
wc
-l
)
"
==
"1"
]
;
then
...
...
@@ -418,9 +418,9 @@ if [ ! -d "$DUMP_DIR/." ]; then
mkdir
-p
$DUMP_DIR
_verbose
"Created dump target directory
$DUMP_DIR
"
fi
if
[
$(
find
$DUMP_DIR
-maxdepth
0
-user
root
-perm
7
0
0 |
wc
-l
)
-ne
1
]
;
then
chown
0:0
"
$DUMP_DIR
/."
chmod
7
0
0
"
$DUMP_DIR
/."
if
[
$(
find
$DUMP_DIR
-maxdepth
0
-user
sympl
-group
sympl
-perm
7
7
0 |
wc
-l
)
-ne
1
]
;
then
chown
sympl:sympl
"
$DUMP_DIR
/."
chmod
7
7
0
"
$DUMP_DIR
/."
_verbose
"Adjusted permissions for
$DUMP_DIR
"
fi
...
...
@@ -444,8 +444,8 @@ for DATABASE in ${MYSQL_TO_DUMP}; do
else
_debug
'Creating dummy file and setting permissions'
touch
$DUMP_FILENAME
chown
0:0
$DUMP_FILENAME
chmod
6
0
0
$DUMP_FILENAME
chown
sympl:sympl
$DUMP_FILENAME
chmod
6
6
0
$DUMP_FILENAME
## determine dump type
### MyISAM tables need to be locked, InnoDB tables don't, and use different dump types
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment