Skip to content

Commit 6e67e90

Browse files
authored
Add Physical Base Backup Support (#13)
Signed-off-by: SK Ali Arman <arman@appscode.com>
1 parent f1c09b3 commit 6e67e90

4 files changed

Lines changed: 56 additions & 2 deletions

File tree

scripts/copy-data.sh

Lines changed: 32 additions & 0 deletions
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/ensure-restore.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ "$PITR_RESTORE" == "true" ]]; then
4+
if [[ "$HOSTNAME" != *"-0" ]]; then
5+
if [[ -f /var/lib/mysql/gvwstate.dat ]]; then
6+
rm /var/lib/mysql/gvwstate.dat
7+
fi
8+
fi
9+
fi
10+
11+
RECOVERY_DONE_FILE="/tmp/recovery.done"
12+
if [[ "$PITR_RESTORE" == "true" ]]; then
13+
while true; do
14+
sleep 2
15+
echo "Point In Time Recovery In Progress. Waiting for $RECOVERY_DONE_FILE file"
16+
if [[ -e "$RECOVERY_DONE_FILE" ]]; then
17+
echo "$RECOVERY_DONE_FILE found."
18+
break
19+
fi
20+
done
21+
fi

scripts/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ while [ true ]; do
2929
if [ -f "/scripts/seqno" ]; then
3030
rm /scripts/seqno
3131
fi
32-
32+
./scripts/ensure-restore.sh
3333
# start on-start script
3434
./scripts/on-start.sh $@
3535
sleep 1

scripts/std-replication-run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ while [ true ]; do
2929
if [ -f "/scripts/seqno" ]; then
3030
rm /scripts/seqno
3131
fi
32-
32+
./scripts/ensure-restore.sh
3333
# start on-start script
3434
./scripts/std-replication-on-start.sh $@
3535
sleep 1
3636
done
37+

0 commit comments

Comments
 (0)