Compare commits
6 Commits
6ddd595b68
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
6c0832c0f0
|
|||
|
72680745ba
|
|||
|
fe1dd2c711
|
|||
|
411aaa7418
|
|||
|
be9f7133a8
|
|||
|
4a784721dd
|
@@ -7,10 +7,8 @@ env:
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
schedule:
|
||||
- cron: "0 12 3 * *"
|
||||
- cron: "0 12 * * 3"
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
workflow_run:
|
||||
|
||||
@@ -6,8 +6,8 @@ env:
|
||||
REPOSITORY: paspo/mariadb-backup-slave
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 14 * * *"
|
||||
# schedule:
|
||||
# - cron: "0 14 * * *"
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
workflow_run:
|
||||
|
||||
10
Dockerfile
10
Dockerfile
@@ -2,16 +2,12 @@ ARG MARIA_VERSION
|
||||
FROM mariadb:${MARIA_VERSION}
|
||||
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -q -y cron sudo automysqlbackup
|
||||
|
||||
COPY mysql.cnf /etc/mysql/mariadb.conf.d/settings.cnf
|
||||
COPY maria-include.cnf /etc/mysql/conf.d/maria-include.cnf
|
||||
COPY custom.cnf /etc/mysql/mariadb.conf.d/custom.cnf
|
||||
COPY rootfs /
|
||||
|
||||
RUN chown mysql:mysql /etc/mysql/mariadb.conf.d/custom.cnf
|
||||
COPY docker-entrypoint-new.sh /usr/local/bin/
|
||||
COPY healthcheck.sh /usr/local/bin/
|
||||
COPY automysqlbackup /etc/default
|
||||
COPY sudoers /etc/sudoers.d/mysudoers
|
||||
|
||||
HEALTHCHECK --interval=30s --start-period=30s --timeout=3s \
|
||||
CMD /usr/local/bin/healthcheck.sh
|
||||
|
||||
@@ -79,7 +79,7 @@ docker-compose up -d
|
||||
Create the database:
|
||||
|
||||
```bash
|
||||
docker exec my-container sh -c 'echo "create database aWordpressDatabase;" | exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD"'
|
||||
docker-compose exec backup-slave sh -c 'echo "create database aWordpressDatabase;" | exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD"'
|
||||
```
|
||||
|
||||
### Freeze the master
|
||||
@@ -109,7 +109,7 @@ The classic way is preferred when you have a big database because it locks the d
|
||||
Now, we need to import the backup from the master, so as we started the slave as readwrite, we can now do this on the slave:
|
||||
|
||||
```bash
|
||||
docker exec my-container sh -c 'mysqldump -C --lock-tables=false --quick -u repluser -h master.host --password="aRandomPassword" aWordpressDatabase | mysql -u root -p"$MYSQL_ROOT_PASSWORD" aWordpressDatabase'
|
||||
docker-compose exec backup-slave sh -c 'mysqldump -C --lock-tables=false --quick -u repluser -h master.host --password="aRandomPassword" aWordpressDatabase | mysql -u root -p"$MYSQL_ROOT_PASSWORD" aWordpressDatabase'
|
||||
```
|
||||
|
||||
Replace **my-container**, **repluser**, **master.host**, **aRandomPassword**, **aWordpressDatabase** with the correct values.
|
||||
@@ -141,10 +141,10 @@ On the slave, copy the dump file in the running container, like this:
|
||||
docker cp thedump.sql.gz my-container:/thedump.sql.gz
|
||||
```
|
||||
|
||||
Then we import it:
|
||||
Then we import it:
|
||||
|
||||
```bash
|
||||
docker exec my-container sh -c 'zcat /thedump.sql.gz | mysql -u root -p"$MYSQL_ROOT_PASSWORD" aWordpressDatabase'
|
||||
docker-compose exec backup-slave sh -c 'zcat /thedump.sql.gz | mysql -u root -p"$MYSQL_ROOT_PASSWORD" aWordpressDatabase'
|
||||
docker exec my-container sh -c 'rm /thedump.sql.gz'
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user