diff options
author | root <root@vps-18a7a2b7.vps.ovh.ca> | 2024-02-14 16:09:01 -0500 |
---|---|---|
committer | root <root@vps-18a7a2b7.vps.ovh.ca> | 2024-02-14 16:09:01 -0500 |
commit | 93a9a34bbac850137a7c722325080c2a8908db97 (patch) | |
tree | 3fcf27e57f746174b9fd2ef85201051a339108f0 | |
parent | d7900be223fedb139be73cd6691449993d71bd47 (diff) |
remove unused mariabackup code
-rwxr-xr-x | src/mariadb-push-replica.sh | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/src/mariadb-push-replica.sh b/src/mariadb-push-replica.sh index 074fcbd..f4077cc 100755 --- a/src/mariadb-push-replica.sh +++ b/src/mariadb-push-replica.sh | |||
@@ -65,41 +65,6 @@ show_hostnames() | |||
65 | "$(uptime)" | 65 | "$(uptime)" |
66 | } | 66 | } |
67 | 67 | ||
68 | create_backup() | ||
69 | { | ||
70 | mostly_silent_unless_error create_backup_verbose "$@" | ||
71 | } | ||
72 | |||
73 | create_backup_verbose() | ||
74 | { | ||
75 | set -e | ||
76 | mariabackup_target_dir=/var/mariadb/backup | ||
77 | binlog_info_file=$mariabackup_target_dir/xtrabackup_binlog_info | ||
78 | [ -e "$binlog_info_file" ] && return | ||
79 | mkdir -p "$mariabackup_target_dir" | ||
80 | set -- \ | ||
81 | -u root \ | ||
82 | --target-dir="$mariabackup_target_dir" \ | ||
83 | "$@" | ||
84 | set -x | ||
85 | mariabackup --backup --rsync "$@" | ||
86 | mariabackup --prepare "$@" | ||
87 | [ -e "$binlog_info_file" ] | ||
88 | } | ||
89 | |||
90 | delete_backup() | ||
91 | { | ||
92 | set -x | ||
93 | rm -r /var/mariadb/backup | ||
94 | } | ||
95 | |||
96 | send_backup() | ||
97 | { | ||
98 | mariabackup_target_dir=/var/mariadb/backup | ||
99 | set -x | ||
100 | rsync -zaR -- /./"${mariabackup_target_dir#/}" "$1":/ | ||
101 | } | ||
102 | |||
103 | stop_mariadb_server_and_remove_database_files() | 68 | stop_mariadb_server_and_remove_database_files() |
104 | { | 69 | { |
105 | livedb=/var/lib/mysql | 70 | livedb=/var/lib/mysql |
@@ -118,31 +83,6 @@ stop_mariadb_server_and_remove_database_files() | |||
118 | chmod --reference="$livedb_backup" "$livedb" | 83 | chmod --reference="$livedb_backup" "$livedb" |
119 | } | 84 | } |
120 | 85 | ||
121 | restore_from_backup() | ||
122 | { | ||
123 | mariabackup_target_dir=/var/mariadb/backup | ||
124 | set -e | ||
125 | stop_mariadb_server_and_remove_database_files | ||
126 | set -- \ | ||
127 | --force-non-empty-directories \ | ||
128 | -u root \ | ||
129 | --target-dir="$mariabackup_target_dir" | ||
130 | set -- "$@" | ||
131 | if mostly_silent_unless_error \ | ||
132 | mariabackup --move-back "$@" | ||
133 | then | ||
134 | # Can't believe mariabackup | ||
135 | # is so primitive as to | ||
136 | # recommend this chown in its | ||
137 | # documentation | ||
138 | chown -R mysql:mysql /var/lib/mysql | ||
139 | systemctl start mariadb | ||
140 | set_server_id | ||
141 | else | ||
142 | exit $? | ||
143 | fi | ||
144 | } | ||
145 | |||
146 | silent_unless_error() | 86 | silent_unless_error() |
147 | { | 87 | { |
148 | set -- "$(mktemp)" "$@" | 88 | set -- "$(mktemp)" "$@" |
@@ -192,38 +132,6 @@ to | |||
192 | . | 132 | . |
193 | } | 133 | } |
194 | 134 | ||
195 | enable_replication_via_mariabackup_xtra_info() | ||
196 | { | ||
197 | primary_host=$1 | ||
198 | replication_user=$2 | ||
199 | replication_password=$3 | ||
200 | mariabackup_target_dir=/var/mariadb/backup | ||
201 | binlog_info_file=$mariabackup_target_dir/xtrabackup_binlog_info | ||
202 | set -e | ||
203 | read \ | ||
204 | master_log_file \ | ||
205 | master_log_pos \ | ||
206 | gtid_slave_pos \ | ||
207 | < $binlog_info_file | ||
208 | mariadb -v --skip-reconnect -t <<. | ||
209 | stop slave; | ||
210 | set global | ||
211 | gtid_slave_pos = '$gtid_slave_pos' | ||
212 | ; | ||
213 | change master | ||
214 | to | ||
215 | master_host = '$primary_host', | ||
216 | master_user = '$replication_user', | ||
217 | master_password = '$replication_password', | ||
218 | master_use_gtid = slave_pos | ||
219 | ; | ||
220 | start slave; | ||
221 | show slave status\g | ||
222 | . | ||
223 | set -x | ||
224 | rm -r /var/mariadb/backup | ||
225 | } | ||
226 | |||
227 | create_replication_user() | 135 | create_replication_user() |
228 | { | 136 | { |
229 | mariadb --skip-reconnect -t <<. | 137 | mariadb --skip-reconnect -t <<. |
@@ -346,21 +254,6 @@ from | |||
346 | . | 254 | . |
347 | } | 255 | } |
348 | 256 | ||
349 | mariabackup_create_replica_databases() | ||
350 | { | ||
351 | run_primary create_backup | ||
352 | run_primary send_backup "$replica_host" | ||
353 | run_replica restore_from_backup | ||
354 | run_primary create_replication_user \ | ||
355 | "$replica_host" \ | ||
356 | "$replication_user" \ | ||
357 | "$replication_password" | ||
358 | run_replica enable_replication_via_mariabackup_xtra_info \ | ||
359 | "$primary_host" \ | ||
360 | "$replication_user" \ | ||
361 | "$replication_password" | ||
362 | } | ||
363 | |||
364 | printlines() | 257 | printlines() |
365 | { | 258 | { |
366 | printf '%s\n' "$@" | 259 | printf '%s\n' "$@" |