Skip to content

Commit d5c4372

Browse files
Fix warnings about mysql legacy paths when using mariadb (#9)
* Fix warnings about mysql legacy paths going away when using mariadb * Update tested versions * Disable unrelated failures for now
1 parent 13d2801 commit d5c4372

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

.github/workflows/molecule.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ jobs:
2727
strategy:
2828
matrix:
2929
image:
30+
#- geerlingguy/docker-ubuntu2404-ansible:latest @todo fix molecule/docker issues
31+
#- geerlingguy/docker-ubuntu2204-ansible:latest @todo fix molecule/docker issues
3032
- geerlingguy/docker-ubuntu2004-ansible:latest
31-
- geerlingguy/docker-ubuntu1804-ansible:latest
32-
- geerlingguy/docker-ubuntu1604-ansible:latest
33-
- geerlingguy/docker-centos7-ansible:latest
3433
- geerlingguy/docker-centos8-ansible:latest
34+
#- geerlingguy/docker-rockylinux9-ansible:latest @todo fix molecule/docker issues
35+
#- geerlingguy/docker-rockylinux10-ansible:latest @todo fix molecule/docker issues
3536
steps:
3637
- name: checkout
3738
uses: actions/checkout@v2

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ Before a database is backed up, old backups are examined to see if they can be p
120120
- Ignore warnings about a specific database: `'^my_db_name$'`
121121
- Ignore warnings about two specific databases: `'^my_db_name$|^my_other_db$'`
122122

123+
* #### simple_mysql_backups_prefer_mariadb_client
124+
- Default: `true`
125+
- If true, and if both `mysql` and `mariadb` clients are installed, the script will use the `mariadb` / `mariadb-dump` clients.
126+
- If no mariadb client is installed, the script will fall back to `mysql` / `mysqldump` clients.
123127

124128
## Troubleshooting
125129

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ simple_mysql_backups_cron_hour: '4'
1818
simple_mysql_backups_cron_day: '*'
1919
simple_mysql_backups_cron_user: root
2020
simple_mysql_backups_cron_state: present
21+
22+
simple_mysql_backups_prefer_mariadb_client: true

scripts/mysql-backups.conf.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ PRUNE_LOG="/var/log/acro/mysql-backups/prune.log"
1111
SPACE_ABORT_THRESHOLD=90
1212
NO_BACKUPS_FOR='^information_schema$|^performance_schema$|^sys$'
1313
IGNORE_EMPTY_DB_PATTERN='.*'
14+
PREFER_MARIADB_CLIENT=1

scripts/mysql-backups.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,33 @@ function main () {
3838
}
3939
export CONFIG
4040

41+
if [ "${PREFER_MARIADB_CLIENT:-1}" -eq 1 ] && command -v mariadb > /dev/null; then
42+
MYSQL=$(command -v mariadb)
43+
elif command -v mysql > /dev/null; then
44+
MYSQL=$(command -v mysql)
45+
else
46+
err "Could not find mysql or mariadb client in path."
47+
exit 1
48+
fi
49+
50+
if [ "${PREFER_MARIADB_CLIENT:-1}" -eq 1 ] && command -v mariadb-dump > /dev/null; then
51+
MYSQLDUMP=$(command -v mariadb-dump)
52+
elif command -v mysqldump > /dev/null; then
53+
MYSQLDUMP=$(command -v mysqldump)
54+
else
55+
err "Could not find mysqldump or mariadb-dump in path."
56+
exit 1
57+
fi
58+
4159
if [ -n "${MY_DEFAULTS:-}" ]; then
4260
# Use a defaults file if one is specified
61+
# The default behaviour is to read options from ~/.my.cnf without having to specify it.
4362
if [ ! -f "${MY_DEFAULTS}" ]; then
4463
err "MY_DEFAULTS is set to '${MY_DEFAULTS}', but that file does not exist."
4564
exit 1
4665
fi
47-
MYSQL="$(command -v mysql) --defaults-file=${MY_DEFAULTS}"
48-
MYSQLDUMP="$(command -v mysqldump) --defaults-file=${MY_DEFAULTS}"
49-
else
50-
# The default behaviour is to read options from ~/.my.cnf without having to specify it.
51-
MYSQL="$(command -v mysql)"
52-
MYSQLDUMP="$(command -v mysqldump)"
66+
MYSQL="$MYSQL --defaults-file=${MY_DEFAULTS}"
67+
MYSQLDUMP="$MYSQLDUMP --defaults-file=${MY_DEFAULTS}"
5368
fi
5469

5570
# Touch the log file to make sure we can write to it.

templates/mysql-backups.conf.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ PRUNE_LOG="{{ simple_mysql_backups_log_dir }}/prune.log"
1515
SPACE_ABORT_THRESHOLD={{ simple_mysql_backups_space_abort_threshold }}
1616
NO_BACKUPS_FOR='{{ simple_mysql_backups_skip_db_pattern }}'
1717
IGNORE_EMPTY_DB_PATTERN='{{ simple_mysql_backups_ignore_empty_db_pattern }}'
18+
PREFER_MARIADB_CLIENT={{ simple_mysql_backups_prefer_mariadb_client | ternary('1', '0') }}

0 commit comments

Comments
 (0)