Skip to content

Commit acfb04b

Browse files
authored
Add PITR Replication Strategy Support & Fix Same Memeber_ID (#40)
Signed-off-by: SK Ali Arman <[email protected]>
1 parent 0176b2c commit acfb04b

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

init-script/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
rm -rf /var/lib/mysql/lost+found
44
rm -rf /run-scripts/*
5+
rm /var/lib/mysql/auto.cnf
56
cp /tmp/scripts/* /scripts

scripts/copy-data.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
ROOT_DIR="$ROOT_DIR"
4+
TOTAL_DIR_TO_COPY="$TOTAL_DIR_TO_COPY"
5+
DATA_DIR="$DATA_DIR"
6+
7+
if [ -z "$ROOT_DIR" ] || [ -z "$TOTAL_DIR_TO_COPY" ]; then
8+
echo "ROOT_DIR and TOTAL_DIR_TO_COPY must be set."
9+
exit 1
10+
fi
11+
Size1=$(du -s "$ROOT_DIR" | cut -f1)
12+
echo "DATA DIRECTORY SIZE: ", $Size1
13+
for (( i = 1; i <= $TOTAL_DIR_TO_COPY; i++ ));do
14+
if [[ -d "$ROOT_DIR$i" ]];then
15+
Size2=$(du -s "$ROOT_DIR$i" | cut -f1)
16+
echo $Size1, " ", $Size2
17+
if [[ "$Size1" == "$Size2" ]];then
18+
continue
19+
fi
20+
fi
21+
# not deleting any data
22+
# because the sole purpose of this script is to copy the data
23+
# rm -rf "$ROOT_DIR$i"/*
24+
rm "$ROOT_DIR/mysql.sock"
25+
cp -rvL "$ROOT_DIR/"* "$ROOT_DIR$i"/
26+
if [[ $? -ne 0 ]]; then
27+
echo "Error occurred while copying to $ROOT_DIR$i"
28+
exit 1
29+
fi
30+
done
31+
32+
exit 0

scripts/run.sh

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@
1515
# POD_IP_TYPE = Address type of POD_IP (one of IPV4, IPv6)
1616

1717
env | sort | grep "POD\|HOST\|NAME"
18+
RECOVERY_DONE_FILE="/tmp/recovery.done"
19+
if [[ "$PITR_RESTORE" == "true" ]]; then
20+
while true; do
21+
sleep 2
22+
echo "Point In Time Recovery In Progress. Waiting for $RECOVERY_DONE_FILE file"
23+
if [[ -e "$RECOVERY_DONE_FILE" ]]; then
24+
echo "$RECOVERY_DONE_FILE found."
25+
break
26+
fi
27+
done
28+
fi
29+
30+
if [[ -e "$RECOVERY_DONE_FILE" ]]; then
31+
rm $RECOVERY_DONE_FILE
32+
fi
1833

1934
args=$@
2035
script_name=${0##*/}

scripts/standalone-run.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
if [[ -z "$TOPOLOGY" ]]; then
4+
RECOVERY_DONE_FILE="/tmp/recovery.done"
5+
if [[ "$PITR_RESTORE" == "true" ]]; then
6+
while true; do
7+
sleep 2
8+
echo "Point In Time Recovery In Progress. Waiting for $RECOVERY_DONE_FILE file"
9+
if [[ -e "$RECOVERY_DONE_FILE" ]]; then
10+
echo "$RECOVERY_DONE_FILE found."
11+
break
12+
fi
13+
done
14+
fi
15+
16+
if [[ -e "$RECOVERY_DONE_FILE" ]]; then
17+
rm $RECOVERY_DONE_FILE
18+
fi
19+
fi

0 commit comments

Comments
 (0)