Skip to content

Commit 2c68aba

Browse files
committed
post-recovery bugfix
1 parent 20d4654 commit 2c68aba

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM openemr/mysql-xtrabackup:1.0.7
2+
3+
RUN rm /root/xbackup-wrapper.sh /root/xrecovery-final.sh
4+
COPY xbackup-wrapper.sh xrecovery-final.sh /root/
5+
RUN chmod a+x /root/*.sh
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
exec > /tmp/xtrabackup-launch.log 2>&1
4+
5+
cd /root
6+
7+
# if you recover into a clean system, initial xbackup.sh init was run back then and should not repeat
8+
if [ -f restore-process-complete ]; then
9+
if [ ! -f xtrabackup.database.txt ]; then
10+
echo openemr > xtrabackup.database.txt
11+
chmod 600 xtrabackup.database.txt
12+
fi
13+
touch allsetup.ok
14+
rm restore-process-complete
15+
fi
16+
17+
if [ ! -f allsetup.ok ]; then
18+
./xbackup.sh -u openemr -a && ./xbackup.sh -t full && touch allsetup.ok && exit 0
19+
exit 1
20+
fi
21+
22+
if [ -f force-full-backup ]; then
23+
rm force-full-backup
24+
./xbackup.sh -t full
25+
exit $?
26+
fi
27+
28+
# I don't like forcing it like this, but if the backup fails one day, we need to try it the next
29+
# here's the problem: manual run during an automated run will cause destruction and havoc and woe
30+
if [ $(date +%u) == 7 ]; then
31+
./xbackup.sh -t full -f
32+
else
33+
./xbackup.sh -t incr -f
34+
fi;
35+
36+
exit $?
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
WORKDIR=/mnt/backups/recovery
4+
5+
if service mysql status; then
6+
echo xrecovery-final: mysql must not be running, yet it is; aborting
7+
exit 1
8+
fi
9+
10+
# Even though MySQL isn't running, I can't just make off with /var/lib/mysql,
11+
# since the container mounts it.
12+
13+
chown -R mysql:mysql $WORKDIR
14+
rm -rf /mnt/backups/prerecovery-mysql-datadir
15+
echo Copying prerecovery state...
16+
mkdir /mnt/backups/prerecovery-mysql-datadir
17+
mv /var/lib/mysql/* /mnt/backups/prerecovery-mysql-datadir
18+
echo Moving restored database into position...
19+
mv -v $WORKDIR/* /var/lib/mysql
20+
echo Done, continuing...
21+
rm -f /root/pending-restore
22+
touch /root/force-full-backup
23+
touch /root/restore-process-complete
24+
exit 0

docker/mysql-xtrabackup/xbackup-wrapper.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ exec > /tmp/xtrabackup-launch.log 2>&1
44

55
cd /root
66

7+
# if you recover into a clean system, initial xbackup.sh init was run back then and should not repeat
8+
if [ -f restore-process-complete ]; then
9+
if [ ! -f xtrabackup.database.txt ]; then
10+
echo openemr > xtrabackup.database.txt
11+
chmod 600 xtrabackup.database.txt
12+
fi
13+
touch allsetup.ok
14+
rm restore-process-complete
15+
fi
16+
717
if [ ! -f allsetup.ok ]; then
818
./xbackup.sh -u openemr -a && ./xbackup.sh -t full && touch allsetup.ok && exit 0
919
exit 1

docker/mysql-xtrabackup/xrecovery-final.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ mv -v $WORKDIR/* /var/lib/mysql
2020
echo Done, continuing...
2121
rm -f /root/pending-restore
2222
touch /root/force-full-backup
23+
touch /root/restore-process-complete
2324
exit 0

0 commit comments

Comments
 (0)