Compare commits

...

224 commits

Author SHA1 Message Date
Fco. Javier Delgado del Hoyo
4bacd0dc7c
Merge pull request from fradelg/bugfix/skip-dump-date
Fixed database name on dumps
2024-12-09 12:35:48 +01:00
Fco. Javier Delgado del Hoyo
1d3c439b65 split test and build jobs 2024-12-09 12:32:31 +01:00
Fco. Javier Delgado del Hoyo
8a15e59c1f skip only timestamps when needed 2024-12-09 12:23:08 +01:00
Fco. Javier Delgado del Hoyo
cff595e634 disable skip comments only when needed 2024-12-08 13:56:43 +01:00
Fco. Javier Delgado del Hoyo
dc253cd1ea stick to client 10.11 version 2024-12-08 12:52:35 +01:00
Fco. Javier Delgado del Hoyo
d5d98e5a7c
Merge pull request from fradelg/dependabot-docker-master-alpine-3.21.0
Bump alpine from 3.20.3 to 3.21.0
2024-12-08 11:46:50 +01:00
Tobias Janke
823343381d
[Feature] Remove duplicate database dumps to save storage space ()
* Replace gzip with deterministic bzip2 compression

* Exclude comments from SQL dump

* Add option to remove duplicates using fdupes

* Revert change to bzip2 as gzip can be deterministic using no-name parameter
2024-12-08 11:12:39 +01:00
dependabot[bot]
aebb29ab64
Bump alpine from 3.20.3 to 3.21.0
Bumps alpine from 3.20.3 to 3.21.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-06 04:39:42 +00:00
Fco. Javier Delgado del Hoyo
8a403d725b
Merge pull request from fradelg/fix/build
Fixed issues in CI testing
2024-09-10 19:54:30 +02:00
Fco. Javier Delgado del Hoyo
dac06953c3
do not mask docker username 2024-09-10 19:52:19 +02:00
Fco. Javier Delgado del Hoyo
a715b4946c
add health check 2024-09-10 19:47:30 +02:00
Fco. Javier Delgado del Hoyo
07213e8135
use service name for dns 2024-09-10 19:37:59 +02:00
Fco. Javier Delgado del Hoyo
353430ff83
move to docker v2 2024-09-10 19:25:10 +02:00
Fco. Javier Delgado del Hoyo
9f3f7bcdfa
Merge pull request from fradelg/dependabot-docker-master-alpine-3.20.3
Bump alpine from 3.20.2 to 3.20.3
2024-09-10 19:15:40 +02:00
dependabot[bot]
23cf857487
Bump alpine from 3.20.2 to 3.20.3
Bumps alpine from 3.20.2 to 3.20.3.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-09 04:30:04 +00:00
Fco. Javier Delgado del Hoyo
da8028abe5
Merge pull request from fradelg/dependabot-docker-master-alpine-3.20.2
Bump alpine from 3.20.1 to 3.20.2
2024-07-26 18:11:00 +02:00
dependabot[bot]
9e325e3ef7
Bump alpine from 3.20.1 to 3.20.2
Bumps alpine from 3.20.1 to 3.20.2.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-23 04:19:30 +00:00
Fco. Javier Delgado del Hoyo
dbece920d6
Merge pull request from fradelg/dependabot-docker-master-alpine-3.20.1
Bump alpine from 3.20.0 to 3.20.1
2024-06-21 18:13:06 +02:00
dependabot[bot]
7fbc2fb79e
Bump alpine from 3.20.0 to 3.20.1
Bumps alpine from 3.20.0 to 3.20.1.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-21 04:44:44 +00:00
Fco. Javier Delgado del Hoyo
6fb2c053e7
Merge pull request from fradelg/dependabot-docker-master-alpine-3.20.0
Bump alpine from 3.19.1 to 3.20.0
2024-05-23 19:55:57 +02:00
dependabot[bot]
efe5430629
Bump alpine from 3.19.1 to 3.20.0
Bumps alpine from 3.19.1 to 3.20.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-23 04:30:24 +00:00
Fco. Javier Delgado del Hoyo
0ac27b1753
Merge pull request from fradelg/dependabot-docker-master-alpine-3.19.1
Bump alpine from 3.19.0 to 3.19.1
2024-01-29 19:56:13 +01:00
dependabot[bot]
d20b5ea8a9
Bump alpine from 3.19.0 to 3.19.1
Bumps alpine from 3.19.0 to 3.19.1.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 04:23:47 +00:00
Fco. Javier Delgado del Hoyo
f01e97f92d
Merge pull request from fradelg/dependabot-docker-master-alpine-3.19.0
Bump alpine from 3.18.5 to 3.19.0
2023-12-09 19:12:29 +01:00
dependabot[bot]
9c84748595
Bump alpine from 3.18.5 to 3.19.0
Bumps alpine from 3.18.5 to 3.19.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-08 04:20:17 +00:00
Fco. Javier Delgado del Hoyo
66ac1288be
Merge pull request from fradelg/dependabot-docker-master-alpine-3.18.5
Bump alpine from 3.18.4 to 3.18.5
2023-12-01 19:10:18 +01:00
dependabot[bot]
a84b82077f
Bump alpine from 3.18.4 to 3.18.5
Bumps alpine from 3.18.4 to 3.18.5.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-01 04:59:07 +00:00
Fco. Javier Delgado del Hoyo
f1a3a6b01f
Merge pull request from nikgli/master
Fixed access denied the PROCESS privilege(s) is required for MySQL > 8.0.21
2023-11-02 10:49:55 +01:00
nikgli
f8addec08f Fixed access denied (at least one of) the PROCESS privilege(s) is required error 2023-11-02 14:28:58 +08:00
Fco. Javier Delgado del Hoyo
057495229e
Merge pull request from fradelg/dependabot-docker-master-alpine-3.18.4
Bump alpine from 3.18.3 to 3.18.4
2023-09-30 11:34:19 +02:00
dependabot[bot]
549f30ef6f
Bump alpine from 3.18.3 to 3.18.4
Bumps alpine from 3.18.3 to 3.18.4.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-29 04:49:58 +00:00
Fco. Javier Delgado del Hoyo
e52061d4fa
Test docker image before pushing to docker hub ()
* update dockerize docker instructions

* use go with alpine

* login to docker hub using action too

* test docker image before building

* extract command from the entrypoint

* change volume path

* user docker compose run and cmd instead entrypoint
2023-09-17 11:01:33 +02:00
Fco. Javier Delgado del Hoyo
4be928f6d0
Upgrade dockerize to 0.7.0 ()
* update dockerize docker instructions

* login to docker hub using action
2023-09-15 19:56:06 +02:00
Fco. Javier Delgado del Hoyo
c217d30c39
Merge pull request from fradelg/dependabot-github_actions-docker-setup-qemu-action-3
Bump docker/setup-qemu-action from 2 to 3
2023-09-15 19:11:01 +02:00
dependabot[bot]
554424bbc5
Bump docker/setup-qemu-action from 2 to 3
Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-15 17:07:34 +00:00
Fco. Javier Delgado del Hoyo
6b19e33340
Merge pull request from fradelg/dependabot-github_actions-docker-setup-buildx-action-3
Bump docker/setup-buildx-action from 2 to 3
2023-09-15 19:07:01 +02:00
dependabot[bot]
895f17a082
Bump docker/setup-buildx-action from 2 to 3
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-13 05:03:02 +00:00
Fco. Javier Delgado del Hoyo
70b282dfec
Merge pull request from fradelg/dependabot-github_actions-actions-checkout-4
Bump actions/checkout from 3 to 4
2023-09-05 19:30:26 +02:00
dependabot[bot]
bcf82ae4e6
Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-05 04:59:56 +00:00
Fco. Javier Delgado del Hoyo
7dd3aa517b
Merge pull request from fradelg/dependabot-docker-master-alpine-3.18.3
Bump alpine from 3.18.2 to 3.18.3
2023-08-12 10:42:07 +02:00
dependabot[bot]
b7c09ddc1c
Bump alpine from 3.18.2 to 3.18.3
Bumps alpine from 3.18.2 to 3.18.3.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-08 04:55:47 +00:00
Fco. Javier Delgado del Hoyo
69f8608858
Merge pull request from fradelg/dependabot-docker-master-alpine-3.18.2
Bump alpine from 3.18.0 to 3.18.2
2023-06-16 20:15:29 +02:00
dependabot[bot]
d772d22dd4
Bump alpine from 3.18.0 to 3.18.2
Bumps alpine from 3.18.0 to 3.18.2.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-16 05:00:59 +00:00
Fco. Javier Delgado del Hoyo
b9d28576ea
Merge pull request from fradelg/dependabot-docker-master-alpine-3.18.0
Bump alpine from 3.17.3 to 3.18.0
2023-05-11 20:59:39 +02:00
dependabot[bot]
e1a26c194c
Bump alpine from 3.17.3 to 3.18.0
Bumps alpine from 3.17.3 to 3.18.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-10 05:01:16 +00:00
Fco. Javier Delgado del Hoyo
494c1ed20a
Merge pull request from fradelg/dependabot-docker-master-alpine-3.17.3
Bump alpine from 3.17.2 to 3.17.3
2023-04-01 11:08:30 +02:00
dependabot[bot]
982600303d
Bump alpine from 3.17.2 to 3.17.3
Bumps alpine from 3.17.2 to 3.17.3.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-30 05:01:41 +00:00
Fco. Javier Delgado del Hoyo
41c9f729ea
Merge pull request from fradelg/dependabot-docker-master-alpine-3.17.2
Bump alpine from 3.17.1 to 3.17.2
2023-02-13 19:31:03 +01:00
dependabot[bot]
9edf0dedaf
Bump alpine from 3.17.1 to 3.17.2
Bumps alpine from 3.17.1 to 3.17.2.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-13 05:06:41 +00:00
Fco. Javier Delgado del Hoyo
19c7f7395d
Merge pull request from g-nardiello/feature-healthcheck
[Feature] Add basic healthcheck
2023-01-20 19:00:55 +01:00
Giuseppe Nardiello
25729c7bc3 Corrected HEALTHY.status typo 2023-01-20 12:04:42 +01:00
Giuseppe Nardiello
96ca5bb74a Corrected HEALTHY.status typo 2023-01-20 12:04:19 +01:00
Fco. Javier Delgado del Hoyo
37334bf3c3
Merge pull request from fradelg/bugfix/ci
Bugfix/ci
2023-01-19 20:22:16 +01:00
Fco. Javier Delgado del Hoyo
d6217926f2 fix minor issues 2023-01-19 20:14:48 +01:00
Fco. Javier Delgado del Hoyo
1f5f594e14 add parenthesis to function syntax 2023-01-19 20:01:21 +01:00
Fco. Javier Delgado del Hoyo
47977b7846 ignore data dir 2023-01-19 19:57:20 +01:00
Fco. Javier Delgado del Hoyo
b0ae6e075d update to ubuntu 22.04 2023-01-19 19:57:03 +01:00
Fco. Javier Delgado del Hoyo
90ad75a24e
Merge pull request from g-nardiello/feature-exit-backup
[Feature] Make backup on container shutdown
2023-01-19 19:32:42 +01:00
Fco. Javier Delgado del Hoyo
8d2e012667
Merge pull request from g-nardiello/patch-restore-latest-sort
[Bugfix] RESTORE_LATEST script sorted by backup date
2023-01-19 19:29:10 +01:00
Giuseppe Nardiello
8eb4379305 Changed find regex to explain date-format 2023-01-17 22:57:09 +01:00
Giuseppe Nardiello
9bd732897e Better wait for crond 2023-01-17 22:23:34 +01:00
Giuseppe Nardiello
81f5e3dc69 Corrected *Healthy* typo 2023-01-10 23:55:38 +01:00
Fco. Javier Delgado del Hoyo
57a90b2880
Merge pull request from fradelg/dependabot-docker-master-alpine-3.17.1
Bump alpine from 3.17.0 to 3.17.1
2023-01-10 19:50:32 +01:00
dependabot[bot]
a2675a3c06
Bump alpine from 3.17.0 to 3.17.1
Bumps alpine from 3.17.0 to 3.17.1.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-10 04:06:46 +00:00
Fco. Javier Delgado del Hoyo
6ef15a2672
Merge pull request from g-nardiello/feature-custom-delete
[Feature] Get out delete script, to allow custom logics
2023-01-09 20:50:08 +01:00
Fco. Javier Delgado del Hoyo
374b26531b
Merge pull request from g-nardiello/patch-syntax-if
[Bugfix] run.sh - Missing default value for INIT_BACKUP
2023-01-09 20:24:17 +01:00
g.nardiello
0dba471e17 Merge branch 'feature-custom-delete' of https://github.com/g-nardiello/docker-mysql-cron-backup into feature-custom-delete 2023-01-06 09:38:01 +01:00
g.nardiello
6b6656c540 Delete strategy moved to new file, as could custom 2023-01-06 09:35:11 +01:00
g.nardiello
ee27961c60 Delete strategy moved to new file, as could custom 2023-01-06 09:29:31 +01:00
g.nardiello
f8307fd40f Improved docs for Healthcheck 2023-01-06 08:43:40 +01:00
g.nardiello
74aa80e2b3 Added EXIT_BACKUP feature with gracefully shutdown 2023-01-05 11:59:16 +01:00
g.nardiello
39d39915e4 Added file-based HEALTHCHECK 2023-01-05 11:55:04 +01:00
g.nardiello
400bb8c95e Added sort algorithm to RESTORE_LATEST script 2023-01-05 11:47:54 +01:00
g.nardiello
218bc5778c Fixed if on line 4 to accept default 0 value 2023-01-05 11:44:39 +01:00
Fco. Javier Delgado del Hoyo
3011a8770a
Merge pull request from fradelg/dependabot-docker-master-alpine-3.17.0
Bump alpine from 3.16.3 to 3.17.0
2022-11-24 21:58:35 +01:00
dependabot[bot]
e975214636
Bump alpine from 3.16.3 to 3.17.0
Bumps alpine from 3.16.3 to 3.17.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-23 04:08:05 +00:00
Fco. Javier Delgado del Hoyo
f02d4d92e1
Merge pull request from fradelg/dependabot-docker-master-alpine-3.16.3
Bump alpine from 3.16.2 to 3.16.3
2022-11-14 20:25:02 +01:00
dependabot[bot]
3d32ab2a13
Bump alpine from 3.16.2 to 3.16.3
Bumps alpine from 3.16.2 to 3.16.3.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-14 04:06:23 +00:00
Fco. Javier Delgado del Hoyo
2de64e836a
Merge pull request from skimpax/master
Add ability to use secrets for all mysql access params
2022-10-19 22:23:56 +02:00
Skimpax
d1f887f83c Add details in README 2022-10-16 21:46:32 +02:00
Skimpax
7bc94755f2 Fix copy/paste errors 2022-10-16 21:46:12 +02:00
Skimpax
4abf8c5d9d Update Readme for secrets use 2022-10-15 07:55:10 +02:00
Skimpax
37a8400103 Add ability to use secrets for mysql access 2022-10-15 07:49:01 +02:00
Fco. Javier Delgado del Hoyo
d07cf4ffb7
Merge pull request from fradelg/dependabot-docker-master-alpine-3.16.2
Bump alpine from 3.16.1 to 3.16.2
2022-08-15 17:17:13 +02:00
Fco. Javier Delgado del Hoyo
9b542daf42 use docker --username instead of docker -u 2022-08-15 10:20:22 +02:00
dependabot[bot]
bde69eaf1a
Bump alpine from 3.16.1 to 3.16.2
Bumps alpine from 3.16.1 to 3.16.2.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-10 04:21:29 +00:00
Fco. Javier Delgado del Hoyo
e4a6fb2593
Merge pull request from fradelg/dependabot-docker-master-alpine-3.16.1
Bump alpine from 3.16.0 to 3.16.1
2022-07-19 21:34:46 +02:00
dependabot[bot]
6b19217285
Bump alpine from 3.16.0 to 3.16.1
Bumps alpine from 3.16.0 to 3.16.1.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-19 04:23:29 +00:00
Fco. Javier Delgado del Hoyo
d172e583b0
Merge pull request from kovtalex/master
adding ssl support
2022-06-18 12:08:16 +02:00
Alexey Kovtunovich
2b43049ff9 fix restore.sh - mysql cmd 2022-06-18 12:25:46 +03:00
Alexey Kovtunovich
35ff2141ea fixed link to SSL configuration manual 2022-06-14 18:33:57 +03:00
Alexey Kovtunovich
6f512df392 fixed link to SSL configuration manual 2022-06-14 18:32:06 +03:00
Alexey Kovtunovich
aca23ddb93 add SSL arguments 2022-06-14 18:18:01 +03:00
Fco. Javier Delgado del Hoyo
795dab6dc4
Merge pull request from fradelg/dependabot-docker-master-alpine-3.16.0
Bump alpine from 3.15.4 to 3.16.0
2022-05-24 20:38:50 +02:00
dependabot[bot]
e8396b9fda
Bump alpine from 3.15.4 to 3.16.0
Bumps alpine from 3.15.4 to 3.16.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-24 04:27:53 +00:00
Fco. Javier Delgado del Hoyo
0bf1a8d7ab
Merge pull request from fradelg/dependabot-github_actions-docker-setup-qemu-action-2
Bump docker/setup-qemu-action from 1 to 2
2022-05-07 12:13:49 +02:00
dependabot[bot]
040b3e4e77
Bump docker/setup-qemu-action from 1 to 2
Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-07 09:53:43 +00:00
Fco. Javier Delgado del Hoyo
0721c4cf8f
Merge pull request from fradelg/dependabot-github_actions-docker-setup-buildx-action-2
Bump docker/setup-buildx-action from 1 to 2
2022-05-07 11:53:11 +02:00
dependabot[bot]
7e9b1fdbcf
Bump docker/setup-buildx-action from 1 to 2
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-06 04:25:29 +00:00
Fco. Javier Delgado del Hoyo
4d4d4dbd6c
Merge pull request from fradelg/dependabot-docker-master-alpine-3.15.4
Bump alpine from 3.15.3 to 3.15.4
2022-04-05 20:20:11 +02:00
dependabot[bot]
f1ba971fa0
Bump alpine from 3.15.3 to 3.15.4
Bumps alpine from 3.15.3 to 3.15.4.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-05 04:26:24 +00:00
Fco. Javier Delgado del Hoyo
4b64ac852f
Merge pull request from fradelg/dependabot-docker-master-alpine-3.15.3
Bump alpine from 3.15.2 to 3.15.3
2022-03-29 20:04:16 +02:00
dependabot[bot]
546533416e
Bump alpine from 3.15.2 to 3.15.3
Bumps alpine from 3.15.2 to 3.15.3.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-29 04:27:05 +00:00
Fco. Javier Delgado del Hoyo
1ed7bc3e12
Merge pull request from fradelg/dependabot-docker-master-alpine-3.15.2
Bump alpine from 3.15.1 to 3.15.2
2022-03-24 10:46:52 +01:00
dependabot[bot]
f30f90ad61
Bump alpine from 3.15.1 to 3.15.2
Bumps alpine from 3.15.1 to 3.15.2.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-24 04:25:15 +00:00
Fco. Javier Delgado del Hoyo
f73f393f19
Merge pull request from fradelg/dependabot-docker-master-alpine-3.15.1
Bump alpine from 3.15.0 to 3.15.1
2022-03-18 18:43:15 +01:00
dependabot[bot]
ca54b7769e
Bump alpine from 3.15.0 to 3.15.1
Bumps alpine from 3.15.0 to 3.15.1.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-18 04:22:42 +00:00
Fco. Javier Delgado del Hoyo
6368925724
Merge pull request from fradelg/dependabot-github_actions-actions-checkout-3
Bump actions/checkout from 2 to 3
2022-03-02 22:14:27 +01:00
dependabot[bot]
331adf57b0
Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-02 04:35:02 +00:00
Fco. Javier Delgado del Hoyo
d16bf5443b
Merge pull request from moty66/master
Fix double quote issue for extra options
2022-02-24 20:51:32 +01:00
Motaz Abuthiab
eb42488f00
fix issue with multiple dump extra options
mysqldump will fail if the env variable has multiple options, 

issue: https://github.com/fradelg/docker-mysql-cron-backup/issues/72
2022-02-22 08:50:03 +01:00
Motaz Abuthiab
db6014ab1a
fix issue with multiple dump extra options
mysqldump will fail if the env variable has multiple options, 

issue: https://github.com/fradelg/docker-mysql-cron-backup/issues/72
2022-02-22 08:49:54 +01:00
Fco. Javier Delgado del Hoyo
42312b94a3
Merge pull request from fradelg/save-plain-sql
support saving non-gzipped sql files
2022-02-05 18:18:33 +01:00
Fco. Javier Delgado del Hoyo
f741822403 fix wrong placement of MYSQLDUMP_OPTS variable 2022-02-05 13:01:53 +01:00
Fco. Javier Delgado del Hoyo
8992f162d7 support saving non-gzipped sql files 2022-02-04 20:44:11 +01:00
Fco. Javier Delgado del Hoyo
f0e5cb6ac8
Merge pull request from skimpax/master
Add ability to get mysql password from file
2022-01-15 18:16:04 +01:00
skimpax
74ad029573 Remove double quotes around MYSQLDUMP_OPTS 2022-01-15 13:54:58 +01:00
skimpax
203280de70 Update readme for docker secrets example 2021-12-30 18:39:02 +01:00
skimpax
a365376ebe Add double quotes 2021-12-30 18:38:31 +01:00
skimpax
9f81b63bcd Ignore 'sys' table when backuping 2021-12-30 18:38:06 +01:00
skimpax
9c7c4d74e3 Specify password in a file via MYSQL_PASS_FILE 2021-12-30 18:37:52 +01:00
Fco. Javier Delgado del Hoyo
b0318b007c
Merge pull request from fradelg/dependabot-docker-master-alpine-3.15.0
Bump alpine from 3.14.3 to 3.15.0
2021-11-25 20:13:54 +01:00
dependabot[bot]
f2ac763df9
Bump alpine from 3.14.3 to 3.15.0
Bumps alpine from 3.14.3 to 3.15.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-25 04:27:29 +00:00
Fco. Javier Delgado del Hoyo
fada8cbe2c
Merge pull request from fradelg/dependabot-docker-master-alpine-3.14.3
Bump alpine from 3.14.2 to 3.14.3
2021-11-16 19:17:59 +01:00
dependabot[bot]
566cbc7c67
Bump alpine from 3.14.2 to 3.14.3
Bumps alpine from 3.14.2 to 3.14.3.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-15 04:27:07 +00:00
Fco. Javier Delgado del Hoyo
0b8a8abbb0
Merge pull request from fradelg/dependabot-docker-master-alpine-3.14.2
Bump alpine from 3.12 to 3.14.2
2021-11-09 18:49:17 +01:00
dependabot[bot]
6f5e7b0eed
Bump alpine from 3.12 to 3.14.2
Bumps alpine from 3.12 to 3.14.2.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-08 22:09:42 +00:00
Fco. Javier Delgado del Hoyo
03ee3a58fe
Merge pull request from waja/dependabot
Adding dependabot config
2021-11-08 23:09:16 +01:00
Jan Wagner
f2cefb1f9f Adding dependabot config 2021-11-08 20:56:01 +01:00
Fco. Javier Delgado del Hoyo
555e9026cb
Merge pull request from Jumanjii/patch-1
Add missing space in if with square bracket
2021-11-08 16:01:46 +01:00
Allan Jacquet-Cretides
db19ca1130
Add missing space in if with square bracket
A missing space at the end of an if condition was generating a warning message.
/restore.sh: line 14: [: missing `]'

Adding it delete this error message
2021-11-07 23:26:56 +01:00
Fco. Javier Delgado del Hoyo
726585bd41
Merge pull request from dlencer/master
Fix unintended deletions of old dumps
2021-10-25 19:54:57 +02:00
dlencer
aa4ddc21d9
Fix unintended deletions of old dumps
Previously, if `mysql` or `mysqldump` failed and you were using the `MAX_BACKUPS`-option, all old dumps were deleted. Now only dumps of successfully detected databases are considered for deletion.
2021-10-21 12:37:55 +02:00
Fco. Javier Delgado del Hoyo
4ee035f7d1
Merge pull request from fradelg/support-hyphen-in-db-name
relax regex in grep from Database
2021-05-24 20:49:49 +02:00
Fco. Javier Delgado del Hoyo
e91114710f relax regex in grep from Database 2021-05-24 20:11:30 +02:00
Fco. Javier Delgado del Hoyo
27ce6e2def
Merge pull request from fradelg/no-root-user
clean and sort Dockerfile
2021-05-13 21:00:28 +02:00
Fco. Javier Delgado del Hoyo
4fb031b087 removed unused package 2021-05-13 20:30:26 +02:00
Fco. Javier Delgado del Hoyo
6c79828e8b fix README 2021-05-13 20:24:13 +02:00
Fco. Javier Delgado del Hoyo
44b2074614 merge branch 'master' into no-root-user 2021-05-13 20:19:08 +02:00
Fco. Javier Delgado del Hoyo
b9c13f99a0
Merge pull request from Stelage/master
Allow restoring without specifying DATABASE_NAME
2021-05-13 20:17:07 +02:00
Stelage
41ea03511f Quotes on SQL var was missing. 2021-05-09 17:58:46 +02:00
Stelage
7c8f51eac3 Fix pipefail position 2021-05-09 17:57:18 +02:00
Fco. Javier Delgado del Hoyo
89bb6f185e log crond output, remove 1000 userid 2021-05-09 11:28:53 +02:00
Fco. Javier Delgado del Hoyo
33c570f26d merge branch 'master' into no-root-user 2021-05-08 22:05:14 +02:00
Fco. Javier Delgado del Hoyo
038d4faf7f allow to run crontab job with userid 1000 2021-05-08 21:58:48 +02:00
Stelage
1302281333 Allow restoring without specifying DATABASE_NAME 2021-05-04 22:59:10 +02:00
Fco. Javier Delgado del Hoyo
ad684b3008
Merge pull request from hasechris/master
Add --single-transaction argument to mysqldump
2021-04-07 20:13:26 +02:00
Christian Hase
9501648ce9
Update backup.sh
added --single-transaction parameter to "halt" the mysql database while exporting
2021-04-07 19:19:42 +02:00
Fco. Javier Delgado del Hoyo
4e5a9162f4 fix typo in tag filter for builds 2021-03-16 19:59:46 +01:00
Fco. Javier Delgado del Hoyo
4d2a75df19 build job depends on tests 2021-03-07 13:05:22 +01:00
Fco. Javier Delgado del Hoyo
2405077482 build dockerize and fix restore.sh db name for issue 2021-03-07 12:57:19 +01:00
Fco. Javier Delgado del Hoyo
150f905567 remove travis and fix ubuntu version 2021-03-06 13:28:03 +01:00
Fco. Javier Delgado del Hoyo
7e748dd82f use the official docker buildx action 2021-03-06 13:03:08 +01:00
Fco. Javier Delgado del Hoyo
7c8bb00622 add test to github action 2021-03-06 12:53:45 +01:00
Fco. Javier Delgado del Hoyo
057b0e823e fix issues in build action 2021-03-06 12:42:35 +01:00
Fco. Javier Delgado del Hoyo
37c242b292 add github action for multiarch docker build 2021-03-06 12:31:31 +01:00
Fco. Javier Delgado del Hoyo
9eda7058f1
Merge pull request from berti92/master
Updated README.md - added Timezone ENV variable
2021-01-09 16:11:05 +01:00
Andreas Treubert
15e8ee7e0f
Update README.md 2021-01-09 15:31:56 +01:00
Fco. Javier Delgado del Hoyo
2e0b339916
Merge pull request from harenber/master
Add mariadb-connector-c package to support newer MySQL versions
2021-01-09 13:49:42 +01:00
Torsten Harenberg
26a7d8ebb0 Add mariadb-connector-c package to support newer MySQL versions
The container does not run with newer (5.8+?) versions of MySQL as the
library to encrypt the password comes in a separate package.

Adding this package to the list of installed packages.
2021-01-07 15:32:36 +01:00
Andreas Treubert
07ec160d53
Update README.md 2020-11-26 16:26:35 +01:00
Fco. Javier Delgado del Hoyo
995f00f257
Merge pull request from Kedu-SCCL/master
Install alpine package 'tzdata' to allow passing timezone as environm…
2020-10-04 11:54:49 +02:00
javier.legido
748381cdd2 Clarify that environment variable 'CRON_TIME' uses UTC timezone 2020-10-03 11:35:01 +02:00
javier.legido
8622152ceb Install alpine package 'tzdata' to allow passing timezone as environment variable: '-e TZ=foo/bar' 2020-10-03 11:29:37 +02:00
Fco. Javier Delgado del Hoyo
b073bbb23f
Merge pull request from berti92/patch-1
Removed --databases
2020-09-19 19:55:47 +02:00
Andreas Treubert
d163a454d7
Update backup.sh 2020-09-14 15:42:46 +02:00
Fco. Javier Delgado del Hoyo
d06c483950
Merge pull request from rscorer/feature/gzip-level
Add ability to set gzip compression level
2020-09-03 19:21:35 +02:00
Richard Scorer
3db704557a Add ability to set gzip compression level 2020-09-03 14:30:21 +01:00
Fco. Javier Delgado del Hoyo
71747a1560
Merge pull request from waja/alpine312
Update to Alpine 3.12 base image
2020-07-07 19:23:27 +02:00
Jan Wagner
86c09693f0 Update to Alpine 3.12 base image 2020-07-06 12:25:54 +02:00
Fco. Javier Delgado del Hoyo
7d0e2c2f44
Merge pull request from bendangelo/master
Use args to select wanted arch and os
2020-06-13 12:14:21 +02:00
Ben D'Angelo
0c29ac1adb Use args to select wanted arch and os 2020-06-08 23:06:39 +08:00
Fco. Javier Delgado del Hoyo
0d11e1b41b
Merge pull request from waja/alpine311
Update alpine baseimage to 3.11
2020-01-07 20:42:58 +01:00
Jan Wagner
e6673d5465 Update alpine baseimage to 3.11 2020-01-07 12:21:59 +01:00
Fco. Javier Delgado del Hoyo
7ab684878d
Merge pull request from fradelg/develop
Count backups per version, not per DB name
2019-08-18 09:50:33 +02:00
Fco. Javier Delgado del Hoyo
592e617005 added docker-compose file for testing and bump base image 2019-07-28 16:45:33 +02:00
Fco. Javier Delgado del Hoyo
7f01602f0f fix issue counting backups per DB 2019-07-28 15:58:55 +02:00
Fco. Javier Delgado del Hoyo
b2a78edcdc
Merge pull request from DanielCambray/patch-1
Error in the doc
2019-01-30 20:14:33 -05:00
Daniel Cambray
84c84b8a07
Error in the doc
The variable CRON_TIME is not set for every day at 03:00
2019-01-29 08:49:51 +01:00
Fco. Javier Delgado del Hoyo
fef252f8a1
Merge pull request from mon555/patch-1
fix typo in README.md
2019-01-23 20:30:32 +01:00
Fco. Javier Delgado del Hoyo
fba3172314
Merge pull request from mmartinortiz/symlink
Creating symlink from absolute path
2019-01-23 20:30:07 +01:00
Mon555
0ffb2c0a1d
fix typo in README.md 2019-01-23 10:14:47 +07:00
Manuel
abba83c99b Creating symlink from absolute path 2018-11-26 21:09:16 +01:00
Fco. Javier Delgado del Hoyo
6fdc59d957
Merge pull request from mmartinortiz/fix-symlink
Fix symlink && increased verbosity
2018-11-13 21:55:44 +01:00
Manuel
2b8cb54d05 Increased verbosity 2018-11-12 21:12:53 +01:00
Manuel
0ca0ac8f68 Fix symlink creation 2018-11-12 21:12:12 +01:00
Manuel
c2055f02c6
Merge pull request from fradelg/master
Merging from base
2018-11-12 21:08:28 +01:00
Fco. Javier Delgado del Hoyo
7e99a5df2a
fix double quote 2018-11-09 19:07:23 +01:00
Fco. Javier Delgado del Hoyo
5153565714
Merge pull request from mmartinortiz/wait-for-database-ready
Using dockerize as entry point
2018-11-09 19:03:18 +01:00
Manuel
a4ed62c9cc Timeout documentation 2018-11-09 16:09:18 +01:00
Manuel
d873499036 Merge branch 'master' into wait-for-database-ready 2018-11-09 16:06:57 +01:00
Manuel
6892d547bb
Merge pull request from mmartinortiz/create-link-to-latest-backup
Create link to latest backup
2018-11-09 15:58:54 +01:00
Manuel
d5eca7afc5
Global MySQL port and timeout variable 2018-11-09 15:55:53 +01:00
Fco. Javier Delgado del Hoyo
1b758659b4
Merge pull request from mmartinortiz/create-link-to-latest-backup
Create link to latest backup
2018-11-08 20:12:02 +01:00
Manuel
fe1028a205
Using dockerize as entry point 2018-11-08 14:46:39 +01:00
Manuel
1bd0e144c9
Ignore error if file does not exist 2018-11-08 14:34:29 +01:00
Manuel
f6e189e931
Aesthetics improvements and docker-compose example 2018-11-08 11:28:04 +01:00
Manuel
bcc8f68f72
Create a link to the latest backup
The symlink is not considered a backup itself and never deleted according to the backup quota
2018-11-08 11:15:00 +01:00
Fco. Javier Delgado del Hoyo
4c71297f03
merge PR from alancnet/master
Enhancements
2018-04-27 09:06:35 +02:00
Alan Colon
2231e88e58 Implement MYSQL_DB and MYSQLDUMP_OPTS options. Accept MYSQL_DATABASE and MYSQL_PASSWORD to maintain parity with _/mysql image options. 2018-04-26 11:08:44 -07:00
Fco. Javier Delgado del Hoyo
72e6aec35f merge pull request 2018-03-21 13:10:11 +01:00
Fco. Javier Delgado del Hoyo
596c121913 use HOST and PORT for table lookup 2018-03-21 13:08:51 +01:00
Fco. Javier Delgado del Hoyo
fb4533079e
merge pull request from waja/flat
Reorder Dockerfile for less layers
2018-02-13 11:25:14 +01:00
Jan Wagner
2b1d2e979a Reorder Dockerfile for less layers 2018-02-12 15:43:58 +01:00
Fco. Javier Delgado del Hoyo
e98c5cdf2c
pull request from waja/alpine37
alpine 3.7
2018-01-30 12:20:55 +01:00
Fco. Javier Delgado del Hoyo
2dd57291af
pull request from waja/docu-fix
Use correct image name
2018-01-30 11:51:18 +01:00
Jan Wagner
29b54da5a8 Update to apline 3.7 2018-01-30 08:32:45 +01:00
Jan Wagner
5e1044ffea Use correct image name 2018-01-30 08:23:18 +01:00
Fco. Javier Delgado del Hoyo
1bbf0149be merge with local repo 2017-09-11 09:59:47 +02:00
Fco. Javier Delgado del Hoyo
071e0ca61e Merge pull request from fradelg/develop
Develop
2017-09-11 09:56:05 +02:00
Fco. Javier Delgado del Hoyo
6a7ecda5fe Merge pull request from sevenval/fix_missing_use_statement
Fixes missing USE statement in SQL dump
2017-09-11 09:48:56 +02:00
Fco. Javier Delgado del Hoyo
3f47ebf87c Merge pull request from sevenval/add_missing_gunzip_to_restore
Adds missing gunzip command
2017-09-11 09:44:12 +02:00
Fco. Javier Delgado del Hoyo
cf9e0bac0d merge COPY in Dockerfile 2017-09-11 09:36:38 +02:00
Markus "Shorty" Uckelmann
95c36b6493 Adds missing gunzip command
This commit adds a gunzip command which extracts the gzip'd SQL dump and
pipes it into the mysql command. Without the restore fails.
2017-09-07 17:18:55 +02:00
Markus "Shorty" Uckelmann
ae753e40a1 Fixes missing USE statement in SQL dump
This commit adds the additional `--databases` option to the mysqldump command.
This adds a `USE database` statement to the beginning of the SQL dump.
Without this one has to provide the database name at restore.
2017-09-07 17:10:15 +02:00
Fco. Javier Delgado del Hoyo
44cdee455a update docker and bash syntax 2017-04-16 11:29:31 +02:00
Fco. Javier Delgado del Hoyo
b3bb91adf7 Merge pull request from waja/fix/path_fix
Removing absolute path, $TARGET includes it already.
2017-04-11 09:25:42 +02:00
Jan Wagner
7770306750 Removing absolute path, $TARGET includes it already. 2017-04-10 08:55:09 +02:00
Fco. Javier Delgado del Hoyo
fc86bcc4cd double quote find expression too 2017-04-08 18:02:18 +02:00
Fco. Javier Delgado del Hoyo
da419c79b1 fix bash syntax accordint to shellcheck 2017-04-08 17:57:23 +02:00
Fco. Javier Delgado del Hoyo
cedc1c36b3 add travis build status badge 2017-04-08 17:32:53 +02:00
Fco. Javier Delgado del Hoyo
47aa233806 add travis for syntax checking 2017-04-08 17:28:35 +02:00
Fco. Javier Delgado del Hoyo
1b801d6f00 Merge pull request from waja/feature/tests
Adding Makefile for running tests via 'make test'
2017-04-08 17:13:06 +02:00
Jan Wagner
658751a5e4 Adding Makefile for running tests via 'make test'
This can be used for local development and even for running at travis-ci.
2017-04-08 16:50:29 +02:00
12 changed files with 569 additions and 61 deletions

19
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "04:00"
pull-request-branch-name:
separator: "-"
open-pull-requests-limit: 10
- package-ecosystem: docker
directory: "/"
schedule:
interval: daily
time: "04:00"
target-branch: "master"
pull-request-branch-name:
separator: "-"
open-pull-requests-limit: 10

33
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,33 @@
name: build docker image
on:
push:
tags:
- "**"
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout the code
uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get latest release version number
id: docker-tag
uses: yuya-takeyama/docker-tag-from-github-ref-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: fradelg
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build multiarch image
run: |
docker buildx build --push \
--tag fradelg/mysql-cron-backup:${{ steps.docker-tag.outputs.tag }} \
--platform linux/amd64,linux/arm/v7,linux/arm64 .

26
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,26 @@
name: build docker image
on:
workflow_dispatch:
push:
branches:
- "**"
jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Test Bash scripts
run: sudo apt-get -qq update && sudo apt-get install -y devscripts shellcheck && make test
- name: Test image
env:
VOLUME_PATH: /tmp/mariadb
DATABASE_NAME: foo
MARIADB_ROOT_PASSWORD: abcd
run: |
docker compose up -d mariadb
docker compose run backup /backup.sh
docker compose run backup /restore.sh /backup/latest.foo.sql.gz
docker compose stop

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
data

View file

@ -1,17 +1,48 @@
FROM alpine
MAINTAINER Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>
FROM golang:1.20.4-alpine3.18 AS binary
RUN apk -U add openssl git
RUN apk add --update bash mysql-client gzip && rm -rf /var/cache/apk/* && mkdir /backup
ARG DOCKERIZE_VERSION=v0.7.0
WORKDIR /go/src/github.com/jwilder
RUN git clone https://github.com/jwilder/dockerize.git && \
cd dockerize && \
git checkout ${DOCKERIZE_VERSION}
WORKDIR /go/src/github.com/jwilder/dockerize
ENV GO111MODULE=on
RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize .
FROM alpine:3.20.3
LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>"
RUN apk add --update \
tzdata \
bash \
gzip \
openssl \
mysql-client=~10.11 \
mariadb-connector-c \
fdupes && \
rm -rf /var/cache/apk/*
COPY --from=binary /go/bin/dockerize /usr/local/bin
ENV CRON_TIME="0 3 * * sun" \
MYSQL_HOST="mysql" \
MYSQL_PORT="3306"
MYSQL_PORT="3306" \
TIMEOUT="10s" \
MYSQLDUMP_OPTS="--quick"
COPY run.sh /run.sh
COPY backup.sh /backup.sh
COPY restore.sh /restore.sh
RUN chmod +x /backup.sh /restore.sh
COPY ["run.sh", "backup.sh", "restore.sh", "/delete.sh", "/"]
RUN mkdir /backup && \
chmod 777 /backup && \
chmod 755 /run.sh /backup.sh /restore.sh /delete.sh && \
touch /mysql_backup.log && \
chmod 666 /mysql_backup.log
VOLUME ["/backup"]
CMD ["/run.sh"]
HEALTHCHECK --interval=2s --retries=1800 \
CMD stat /HEALTHY.status || exit 1
CMD dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh

25
Makefile Normal file
View file

@ -0,0 +1,25 @@
# Makefile
all: test
test:
# Checking for syntax errors
set -e; for SCRIPT in *.sh; \
do \
bash -n $$SCRIPT; \
done
# Checking for bashisms (currently not failing, but only listing)
SCRIPT="$$(which checkbashisms)"; if [ -n "$$SCRIPT" ] && [ -x "$$SCRIPT" ]; \
then \
$$SCRIPT *.sh || true; \
else \
echo "WARNING: skipping bashism test - you need to install checkbashism."; \
fi
SCRIPT="$$(which shellcheck)"; if [ -n "$$SCRIPT" ] && [ -x "$$SCRIPT" ]; \
then \
$$SCRIPT *.sh || true; \
else \
echo "WARNING: skipping shellcheck test - you need to install shellcheck."; \
fi

264
README.md
View file

@ -1,34 +1,258 @@
# mysql-cron-backup
This image runs mysqldump to backup database periodically using cron. Data is dumped to the container folder `/backup`
Run mysqldump to backup your databases periodically using the cron task manager in the container. Your backups are saved in `/backup`. You can mount any directory of your host or a docker volumes in /backup. Othwerwise, a docker volume is created in the default location.
## Usage:
docker run -d \
--env MYSQL_USER=admin \
--env MYSQL_PASS=password \
--link mysql
--volume /path/to/my/host/folder:/backup
fradelg/mysql-backup
```bash
docker container run -d \
--env MYSQL_USER=root \
--env MYSQL_PASS=my_password \
--link mysql
--volume /path/to/my/backup/folder:/backup
fradelg/mysql-cron-backup
```
### Healthcheck
Healthcheck is provided as a basic init control.
Container is **Healthy** after the database init phase, that is after `INIT_BACKUP` or `INIT_RESTORE_LATEST` happends without check if there is an error, **Starting** otherwise. Not other checks are actually provided.
## Variables
MYSQL_HOST the host/ip of your mysql database
MYSQL_PORT the port number of your mysql database
MYSQL_USER the username of your mysql database
MYSQL_PASS the password of your mysql database
MYSQL_DB the database name to dump. Default: `--all-databases`
CRON_TIME the interval of cron job to run mysqldump. `0 0 * * *` by default, which is every day at 00:00
MAX_BACKUPS the number of backups to keep. When reaching the limit, the old backup will be discarded. No limit by default
INIT_BACKUP if set, create a backup when the container starts
INIT_RESTORE_LATEST if set, restores latest backup
- `MYSQL_HOST`: The host/ip of your mysql database.
- `MYSQL_HOST_FILE`: The file in container where to find the host of your mysql database (cf. docker secrets). You should use either MYSQL_HOST_FILE or MYSQL_HOST (see examples below).
- `MYSQL_PORT`: The port number of your mysql database.
- `MYSQL_USER`: The username of your mysql database.
- `MYSQL_USER_FILE`: The file in container where to find the user of your mysql database (cf. docker secrets). You should use either MYSQL_USER_FILE or MYSQL_USER (see examples below).
- `MYSQL_PASS`: The password of your mysql database.
- `MYSQL_PASS_FILE`: The file in container where to find the password of your mysql database (cf. docker secrets). You should use either MYSQL_PASS_FILE or MYSQL_PASS (see examples below).
- `MYSQL_DATABASE`: The database name to dump. Default: `--all-databases`.
- `MYSQL_DATABASE_FILE`: The file in container where to find the database name(s) in your mysql database (cf. docker secrets). In that file, there can be several database names: one per line. You should use either MYSQL_DATABASE or MYSQL_DATABASE_FILE (see examples below).
- `MYSQLDUMP_OPTS`: Command line arguments to pass to mysqldump (see [mysqldump documentation](https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html)).
- `MYSQL_SSL_OPTS`: Command line arguments to use [SSL](https://dev.mysql.com/doc/refman/5.6/en/using-encrypted-connections.html).
- `CRON_TIME`: The interval of cron job to run mysqldump. `0 3 * * sun` by default, which is every Sunday at 03:00. It uses UTC timezone.
- `MAX_BACKUPS`: The number of backups to keep. When reaching the limit, the old backup will be discarded. No limit by default.
- `INIT_BACKUP`: If set, create a backup when the container starts.
- `INIT_RESTORE_LATEST`: If set, restores latest backup.
- `EXIT_BACKUP`: If set, create a backup when the container stops.
- `TIMEOUT`: Wait a given number of seconds for the database to be ready and make the first backup, `10s` by default. After that time, the initial attempt for backup gives up and only the Cron job will try to make a backup.
- `GZIP_LEVEL`: Specify the level of gzip compression from 1 (quickest, least compressed) to 9 (slowest, most compressed), default is 6.
- `USE_PLAIN_SQL`: If set, back up and restore plain SQL files without gzip.
- `TZ`: Specify TIMEZONE in Container. E.g. "Europe/Berlin". Default is UTC.
- `REMOVE_DUPLICATES`: Use [fdupes](https://github.com/adrianlopezroche/fdupes) to remove duplicate database dumps
If you want to make this image the perfect companion of your MySQL container, use [docker-compose](https://docs.docker.com/compose/). You can add more services that will be able to connect to the MySQL image using the name `my_mariadb`, note that you only expose the port `3306` internally to the servers and not to the host:
### Docker-compose with MYSQL_PASS env var:
```yaml
version: "2"
services:
mariadb:
image: mariadb
container_name: my_mariadb
expose:
- 3306
volumes:
- data:/var/lib/mysql
# If there is not scheme, restore the last created backup (if exists)
- ${VOLUME_PATH}/backup/latest.${DATABASE_NAME}.sql.gz:/docker-entrypoint-initdb.d/database.sql.gz
environment:
- MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
- MYSQL_DATABASE=${DATABASE_NAME}
restart: unless-stopped
mysql-cron-backup:
image: fradelg/mysql-cron-backup
depends_on:
- mariadb
volumes:
- ${VOLUME_PATH}/backup:/backup
environment:
- MYSQL_HOST=my_mariadb
- MYSQL_USER=root
- MYSQL_PASS=${MARIADB_ROOT_PASSWORD}
- MAX_BACKUPS=15
- INIT_BACKUP=0
# Every day at 03:00
- CRON_TIME=0 3 * * *
# Make it small
- GZIP_LEVEL=9
# As of MySQL 8.0.21 this is needed
- MYSQLDUMP_OPTS=--no-tablespaces
restart: unless-stopped
volumes:
data:
```
### Docker-compose using docker secrets:
The database root password passed to docker container by using [docker secrets](https://docs.docker.com/engine/swarm/).
In example below, docker is in classic 'docker engine mode' (iow. not swarm mode) and secret sources are local files on host filesystem.
Alternatively, secrets can be stored in docker secrets engine (iow. not in host filesystem).
```yaml
version: "3.7"
secrets:
# Place your secret file somewhere on your host filesystem, with your password inside
mysql_root_password:
file: ./secrets/mysql_root_password
mysql_user:
file: ./secrets/mysql_user
mysql_password:
file: ./secrets/mysql_password
mysql_database:
file: ./secrets/mysql_database
services:
mariadb:
image: mariadb:10
container_name: my_mariadb
expose:
- 3306
volumes:
- data:/var/lib/mysql
- ${VOLUME_PATH}/backup:/backup
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
- MYSQL_USER_FILE=/run/secrets/mysql_user
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
- MYSQL_DATABASE_FILE=/run/secrets/mysql_database
secrets:
- mysql_root_password
- mysql_user
- mysql_password
- mysql_database
restart: unless-stopped
backup:
build: .
image: fradelg/mysql-cron-backup
depends_on:
- mariadb
volumes:
- ${VOLUME_PATH}/backup:/backup
environment:
- MYSQL_HOST=my_mariadb
# Alternatively to MYSQL_USER_FILE, we can use MYSQL_USER=root to use root user instead
- MYSQL_USER_FILE=/run/secrets/mysql_user
# Alternatively, we can use /run/secrets/mysql_root_password when using root user
- MYSQL_PASS_FILE=/run/secrets/mysql_password
- MYSQL_DATABASE_FILE=/run/secrets/mysql_database
- MAX_BACKUPS=10
- INIT_BACKUP=1
- CRON_TIME=0 0 * * *
secrets:
- mysql_user
- mysql_password
- mysql_database
restart: unless-stopped
volumes:
data:
```
## Restore from a backup
See the list of backups, you can run:
### List all available backups :
docker exec backup ls /backup
See the list of backups in your running docker container, just write in your favorite terminal:
To restore database from a certain backup, simply run:
```bash
docker container exec <your_mysql_backup_container_name> ls /backup
```
docker exec backup /restore.sh /backup/2015.08.06.171901
### Restore using a compose file
To restore a database from a certain backup you may have to specify the database name in the variable MYSQL_DATABASE:
```YAML
mysql-cron-backup:
image: fradelg/mysql-cron-backup
command: "/restore.sh /backup/201708060500.${DATABASE_NAME}.sql.gz"
depends_on:
- mariadb
volumes:
- ${VOLUME_PATH}/backup:/backup
environment:
- MYSQL_HOST=my_mariadb
- MYSQL_USER=root
- MYSQL_PASS=${MARIADB_ROOT_PASSWORD}
- MYSQL_DATABASE=${DATABASE_NAME}
```
### Restore using a docker command
```bash
docker container exec <your_mysql_backup_container_name> /restore.sh /backup/<your_sql_backup_gz_file>
```
if no database name is specified, `restore.sh` will try to find the database name from the backup file.
### Automatic backup and restore on container starts and stops
Set `INIT_RESTORE_LATEST` to automatic restore the last backup on startup.
Set `EXIT_BACKUP` to automatic create a last backup on shutdown.
```yaml
mysql-cron-backup:
image: fradelg/mysql-cron-backup
depends_on:
- mariadb
volumes:
- ${VOLUME_PATH}/backup:/backup
environment:
- MYSQL_HOST=my_mariadb
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASS=${MYSQL_PASSWORD}
- MAX_BACKUPS=15
- INIT_RESTORE_LATEST=1
- EXIT_BACKUP=1
# Every day at 03:00
- CRON_TIME=0 3 * * *
# Make it small
- GZIP_LEVEL=9
restart: unless-stopped
volumes:
data:
```
Docker database image could expose a directory you could add files as init sql script.
```yaml
mysql:
image: mysql
expose:
- 3306
volumes:
- data:/var/lib/mysql
# If there is not scheme, restore using the init script (if exists)
- ./init-script.sql:/docker-entrypoint-initdb.d/database.sql.gz
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${DATABASE_NAME}
restart: unless-stopped
```
```yaml
mariadb:
image: mariadb
expose:
- 3306
volumes:
- data:/var/lib/mysql
# If there is not scheme, restore using the init script (if exists)
- ./init-script.sql:/docker-entrypoint-initdb.d/database.sql.gz
environment:
- MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
- MYSQL_DATABASE=${DATABASE_NAME}
restart: unless-stopped
```

82
backup.sh Normal file → Executable file
View file

@ -1,29 +1,67 @@
#!/bin/bash
[ -z "${MYSQL_USER}" ] && { echo "=> MYSQL_USER cannot be empty" && exit 1; }
[ -z "${MYSQL_PASS}" ] && { echo "=> MYSQL_PASS cannot be empty" && exit 1; }
DATE=`date +%Y%m%d%H%M`
echo "=> Backup started at $DATE"
databases=`mysql -u $MYSQL_USER -p$MYSQL_PASS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
echo "Dumping database: $db"
# Get hostname: try read from file, else get from env
[ -z "${MYSQL_HOST_FILE}" ] || { MYSQL_HOST=$(head -1 "${MYSQL_HOST_FILE}"); }
[ -z "${MYSQL_HOST}" ] && { echo "=> MYSQL_HOST cannot be empty" && exit 1; }
# Get username: try read from file, else get from env
[ -z "${MYSQL_USER_FILE}" ] || { MYSQL_USER=$(head -1 "${MYSQL_USER_FILE}"); }
[ -z "${MYSQL_USER}" ] && { echo "=> MYSQL_USER cannot be empty" && exit 1; }
# Get password: try read from file, else get from env, else get from MYSQL_PASSWORD env
[ -z "${MYSQL_PASS_FILE}" ] || { MYSQL_PASS=$(head -1 "${MYSQL_PASS_FILE}"); }
[ -z "${MYSQL_PASS:=$MYSQL_PASSWORD}" ] && { echo "=> MYSQL_PASS cannot be empty" && exit 1; }
# Get database name(s): try read from file, else get from env
# Note: when from file, there can be one database name per line in that file
[ -z "${MYSQL_DATABASE_FILE}" ] || { MYSQL_DATABASE=$(cat "${MYSQL_DATABASE_FILE}"); }
# Get level from env, else use 6
[ -z "${GZIP_LEVEL}" ] && { GZIP_LEVEL=6; }
DATE=$(date +%Y%m%d%H%M)
echo "=> Backup started at $(date "+%Y-%m-%d %H:%M:%S")"
DATABASES=${MYSQL_DATABASE:-${MYSQL_DB:-$(mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database)}}
for db in ${DATABASES}
do
if [[ "$db" != "information_schema" ]] \
&& [[ "$db" != "performance_schema" ]] \
&& [[ "$db" != "mysql" ]] \
&& [[ "$db" != "sys" ]] \
&& [[ "$db" != _* ]]
then
echo "==> Dumping database: $db"
FILENAME=/backup/$DATE.$db.sql
if mysqldump -h $MYSQL_HOST -P $MYSQL_PORT -u $MYSQL_USER -p$MYSQL_PASS $db > $FILENAME ;then
gzip -f $FILENAME
LATEST=/backup/latest.$db.sql
BASIC_OPTS="--single-transaction"
if [ -n "$REMOVE_DUPLICATES" ]
then
BASIC_OPTS="$BASIC_OPTS --skip-dump-date"
fi
if mysqldump $BASIC_OPTS $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME"
then
EXT=
if [ -z "${USE_PLAIN_SQL}" ]
then
echo "==> Compressing $db with LEVEL $GZIP_LEVEL"
gzip "-$GZIP_LEVEL" -n -f "$FILENAME"
EXT=.gz
FILENAME=$FILENAME$EXT
LATEST=$LATEST$EXT
fi
BASENAME=$(basename "$FILENAME")
echo "==> Creating symlink to latest backup: $BASENAME"
rm "$LATEST" 2> /dev/null
cd /backup || exit && ln -s "$BASENAME" "$(basename "$LATEST")"
if [ -n "$REMOVE_DUPLICATES" ]
then
echo "==> Removing duplicate database dumps"
fdupes -idN /backup/
fi
if [ -n "$MAX_BACKUPS" ]
then
# Execute the delete script, delete older backup or other custom delete script
/delete.sh "$db" $EXT
fi
else
rm -rf $FILENAME
rm -rf "$FILENAME"
fi
fi
done
if [ -n "$MAX_BACKUPS" ]; then
while [ `ls -1 /backup | wc -l` -gt "$MAX_BACKUPS" ];
do
TARGET=`ls -1 /backup | sort | head -n 1`
echo "Backup ${TARGET} is deleted"
rm -rf /backup/${TARGET}
done
fi
echo "=> Backup done"
echo "=> Backup process finished at $(date "+%Y-%m-%d %H:%M:%S")"

14
delete.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
db=$1
EXT=$2
# This file could be customized to create custom delete strategy
while [ "$(find /backup -maxdepth 1 -name "*.$db.sql$EXT" -type f | wc -l)" -gt "$MAX_BACKUPS" ]
do
TARGET=$(find /backup -maxdepth 1 -name "*.$db.sql$EXT" -type f | sort | head -n 1)
echo "==> Max number of ($MAX_BACKUPS) backups reached. Deleting ${TARGET} ..."
rm -rf "${TARGET}"
echo "==> Backup ${TARGET} deleted"
done

40
docker-compose.yaml Normal file
View file

@ -0,0 +1,40 @@
services:
mariadb:
image: mariadb:10.11
container_name: my_mariadb
security_opt:
- seccomp:unconfined
expose:
- 3306
volumes:
- data:/var/lib/mysql
- ${VOLUME_PATH}/backup:/backup
environment:
- MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
- MYSQL_ALLOW_EMPTY_ROOT_PASSWORD=yes
restart: unless-stopped
healthcheck:
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect" ]
timeout: 5s
retries: 10
backup:
build: .
image: fradelg/mysql-cron-backup
depends_on:
mariadb:
condition: service_healthy
volumes:
- ${VOLUME_PATH}/backup:/backup
environment:
- MYSQL_HOST=my_mariadb
- MYSQL_USER=root
- MYSQL_PASS=${MARIADB_ROOT_PASSWORD}
- MAX_BACKUPS=1
- INIT_BACKUP=1
- CRON_TIME=0 0 * * *
restart: unless-stopped
volumes:
data:

40
restore.sh Normal file → Executable file
View file

@ -1,6 +1,42 @@
#!/bin/bash
echo "=> Restore database from \$1"
if mysql -h $MYSQL_HOST -P $MYSQL_POR -u $MYSQL_USER -p$MYSQL_PASS < \$1 ;then
# Get hostname: try read from file, else get from env
[ -z "${MYSQL_HOST_FILE}" ] || { MYSQL_HOST=$(head -1 "${MYSQL_HOST_FILE}"); }
[ -z "${MYSQL_HOST}" ] && { echo "=> MYSQL_HOST cannot be empty" && exit 1; }
# Get username: try read from file, else get from env
[ -z "${MYSQL_USER_FILE}" ] || { MYSQL_USER=$(head -1 "${MYSQL_USER_FILE}"); }
[ -z "${MYSQL_USER}" ] && { echo "=> MYSQL_USER cannot be empty" && exit 1; }
# Get password: try read from file, else get from env, else get from MYSQL_PASSWORD env
[ -z "${MYSQL_PASS_FILE}" ] || { MYSQL_PASS=$(head -1 "${MYSQL_PASS_FILE}"); }
[ -z "${MYSQL_PASS:=$MYSQL_PASSWORD}" ] && { echo "=> MYSQL_PASS cannot be empty" && exit 1; }
if [ "$#" -ne 1 ]
then
echo "You must pass the path of the backup file to restore"
exit 1
fi
set -o pipefail
if [ -z "${USE_PLAIN_SQL}" ]
then
SQL=$(gunzip -c "$1")
else
SQL=$(cat "$1")
fi
DB_NAME=${MYSQL_DATABASE:-${MYSQL_DB}}
if [ -z "${DB_NAME}" ]
then
echo "=> Searching database name in $1"
DB_NAME=$(echo "$SQL" | grep -oE '(Database: (.+))' | cut -d ' ' -f 2)
fi
[ -z "${DB_NAME}" ] && { echo "=> Database name not found" && exit 1; }
echo "=> Restore database $DB_NAME from $1"
if echo "$SQL" | mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$DB_NAME"
then
echo "=> Restore succeeded"
else
echo "=> Restore failed"

37
run.sh
View file

@ -1,21 +1,42 @@
#!/bin/bash
touch /mysql_backup.log
tail -F /mysql_backup.log &
if [ -n "${INIT_BACKUP}" ]; then
if [ "${INIT_BACKUP:-0}" -gt "0" ]; then
echo "=> Create a backup on the startup"
/backup.sh
elif [ -n "${INIT_RESTORE_LATEST}" ]; then
echo "=> Restore latest backup"
until nc -z $MYSQL_HOST $MYSQL_PORT
until nc -z "$MYSQL_HOST" "$MYSQL_PORT"
do
echo "waiting database container..."
sleep 1
done
ls -d -1 /backup/* | tail -1 | xargs /restore.sh
# Needed to exclude the 'latest.<database>.sql.gz' file, consider only filenames starting with number
# Only data-tagged backups, eg. '202212250457.database.sql.gz', must be trapped by the regex
find /backup -maxdepth 1 -name '[0-9]*.*.sql.gz' | sort | tail -1 | xargs /restore.sh
fi
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /crontab.conf
crontab /crontab.conf
echo "=> Running cron task manager"
exec crond -f
function final_backup {
echo "=> Captured trap for final backup"
echo "=> Requested last backup at $(date "+%Y-%m-%d %H:%M:%S")"
exec /backup.sh
exit 0
}
if [ -n "${EXIT_BACKUP}" ]; then
echo "=> Listening on container shutdown gracefully to make last backup before close"
trap final_backup SIGHUP SIGINT SIGTERM
fi
touch /HEALTHY.status
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf
crontab /tmp/crontab.conf
echo "=> Running cron task manager in foreground"
crond -f -l 8 -L /mysql_backup.log &
echo "Listening on crond, and wait..."
tail -f /dev/null & wait $!
echo "Script is shutted down."