refs #8414 - modify maribackup config files and templates
This commit is contained in:
parent
9b809f168a
commit
ef9c1d54e1
|
@ -32,13 +32,14 @@ required_directories:
|
|||
- { path: /mnt/mysqlbin/binlog, owner: mysql, group: mysql, mode: 'u=rwx,g=,o=' }
|
||||
- { path: /root/scripts, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
|
||||
- { path: /root/mariabackup, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
|
||||
- { path: /mnt/mysqldata/mysql, owner: mysql, group: mysql, mode: 'u=rwx,g=rx,o=rx' }
|
||||
required_files_and_mariabackup_files_and_root_scripts:
|
||||
- { src: "mariadb_override.conf", dest: "/etc/systemd/system/mariadb.service.d/override.conf", mode: "u=rw,g=r,o=r" }
|
||||
- { src: "mysql-flush.sh", dest: "/etc/qemu/fsfreeze-hook.d/mysql-flush.sh", mode: "u=rwx,g=rx,o=rx" }
|
||||
- { src: "files/mariabackup/bacula-after.sh", dest: "/root/mariabackup/bacula-after.sh", mode: "u=rwx,g=rx,o=rx" }
|
||||
- { src: "files/mariabackup/bacula-before.sh", dest: "/root/mariabackup/bacula-before.sh", mode: "u=rwx,g=rx,o=rx" }
|
||||
- { src: "files/mariabackup/config.sh", dest: "/root/mariabackup/config.sh", mode: "u=rwx,g=rx,o=x" }
|
||||
- { src: "files/mariabackup/inc-backup.sh", dest: "/root/mariabackup/inc-backup.sh", mode: "u=rwx,g=rx,o=rx" }
|
||||
- { src: "files/mariabackup/my.cnf", dest: "/root/mariabackup/my.cnf", mode: "u=rw,g=,o=" }
|
||||
- { src: "files/mariabackup/restore-backup.sh", dest: "/root/mariabackup/restore-backup.sh", mode: "u=rwx,g=rx,o=rx" }
|
||||
- { src: "files/scripts/check-memory.sh", dest: "/root/scripts/check-memory.sh", mode: "u=rwx,g=rx,o=rx" }
|
||||
- { src: "files/scripts/export-privs.sh", dest: "/root/scripts/export-privs.sh", mode: "u=rwx,g=rx,o=rx" }
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
myDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
. "$myDir/config.sh"
|
||||
. "$myDir/apply.config.sh"
|
||||
|
||||
todayDir=$(date +%Y-%m-%d)
|
||||
pattern="$baculaDir/mnt/local-backup/${todayDir}_??-??_full.gz"
|
||||
files=($pattern)
|
||||
backupFile="${files[0]}"
|
||||
|
||||
"$myDir/restore-backup.sh" "$backupFile"
|
||||
rm -r "$baculaDir"
|
||||
|
||||
if [[ "${#dbClusterSiblings[@]}" -gt "0" ]]; then
|
||||
for node in "${dbClusterSiblings[@]}"; do
|
||||
ssh root@$node service mysql stop
|
||||
ssh root@$node "if pgrep mariadbd; then pkill -9 mariadbd; fi"
|
||||
done
|
||||
|
||||
galera_new_cluster
|
||||
else
|
||||
service mariadb start
|
||||
fi
|
||||
|
||||
echo "Applying custom script."
|
||||
mysql -e "UPDATE util.config SET environment = '$dbEnvironment', lastDump = NOW()"
|
||||
mysql < "$myDir/apply.sql"
|
||||
|
||||
echo "Upgrading tables."
|
||||
mysql_upgrade
|
||||
|
||||
echo "Applying repository changes."
|
||||
curl --silent --request POST --location --user "$jenkinsAuth" "$jenkinsUrl/build?delay=0sec"
|
||||
|
||||
echo "Waiting for Jenkins job to end."
|
||||
jobResult=null
|
||||
while [ "$jobResult" = "null" ]; do
|
||||
sleep 10
|
||||
jobResult=$(curl --silent --location --user "$jenkinsAuth" "$jenkinsUrl/lastBuild/api/json" | jq --raw-output ".result")
|
||||
done
|
||||
echo "Job result: $jobResult"
|
||||
|
||||
echo "Promoting to master."
|
||||
"/root/scripts/promote-master.sh"
|
||||
|
||||
for node in "${dbClusterSiblings[@]}"; do
|
||||
ssh root@$node service mysql start
|
||||
done
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
UPDATE vn2008.tblContadores
|
||||
SET dbproduccion = FALSE;
|
||||
|
||||
DELETE FROM util.binlogQueue;
|
||||
|
||||
UPDATE `account`.`user` SET `active` = TRUE WHERE `name` = 'mindshore';
|
|
@ -124,6 +124,60 @@
|
|||
- "files/mariaconfigfiles/z90-vn.cnf"
|
||||
- "files/mariaconfigfiles/z92-testing.cnf"
|
||||
notify: restart-mariadb
|
||||
|
||||
# - name: Extracting passwords
|
||||
# no_log: true
|
||||
# set_fact:
|
||||
# jenkins_token: "{{ lookup(passbolt, jenkins_user_name, folder_parent_id=passbolt_folder).password }}"
|
||||
|
||||
# - name: Debug variable
|
||||
# debug:
|
||||
# msg: "{{ jenkins_token }}"
|
||||
|
||||
- name: Set MariaBackup custom configuration Test
|
||||
template:
|
||||
src: "apply.config-test.sh"
|
||||
dest: /root/mariabackup/apply.config.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: u=rw,g=r,o=r
|
||||
|
||||
- name: Extracting dbusername
|
||||
set_fact:
|
||||
dbusername: "{{ lookup(passbolt, dbuser, folder_parent_id=passbolt_folder).username }}"
|
||||
|
||||
- name: Extracting dbpassword
|
||||
no_log: true
|
||||
set_fact:
|
||||
dbpass: "{{ lookup(passbolt, dbuser, folder_parent_id=passbolt_folder).password }}"
|
||||
|
||||
- name: Extracting MariaBackup UserName
|
||||
set_fact:
|
||||
mariabackupusernametpl: "{{ lookup(passbolt, mariabackupusername, folder_parent_id=passbolt_folder).username }}"
|
||||
|
||||
- name: Extracting MariaBackup Password
|
||||
no_log: true
|
||||
set_fact:
|
||||
mariabackuppasstpl: "{{ lookup(passbolt, mariabackupusername, folder_parent_id=passbolt_folder).password }}"
|
||||
|
||||
- name: Set MariaBackup custom template configuration Test
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: /root/mariabackup/
|
||||
owner: root
|
||||
group: root
|
||||
mode: u=rw,g=,o=
|
||||
with_items:
|
||||
- "apply.cnf"
|
||||
- "my.cnf"
|
||||
|
||||
- name: Set MariaDB local configuration file
|
||||
copy:
|
||||
src: files/mariabackuptest/apply.sql
|
||||
dest: /root/mariabackup/
|
||||
owner: root
|
||||
group: root
|
||||
mode: u=rw,g=r,o=r
|
||||
|
||||
- name: Reminder to check mount points
|
||||
debug:
|
||||
|
@ -132,7 +186,7 @@
|
|||
- /mnt/mysqltmp
|
||||
Make sure they are correctly configured and accessible.
|
||||
|
||||
- name: Set MariaDB local configuration file
|
||||
- name:
|
||||
template:
|
||||
src: templates/z99-local.cnf
|
||||
dest: /etc/mysql/mariadb.conf.d/
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[client]
|
||||
host = localhost
|
||||
user = {{ dbusername }}
|
||||
password = {{ dbpass }}
|
||||
socket = /var/run/mysqld/mysqld.sock
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Bacula directory for restore
|
||||
baculaDir=/mnt/mysqldata/bacula-restore
|
||||
|
||||
# Database branch name
|
||||
dbBranch=test
|
||||
|
||||
# Database environment
|
||||
dbEnvironment=test
|
||||
|
||||
# MariaDB cluster sibling node hostnames
|
||||
dbClusterSiblings=()
|
||||
|
||||
# Jenkins authentication string
|
||||
jenkinsAuth=jenkins:{{ lookup(passbolt, 'jenkinsAuth', folder_parent_id=passbolt_folder).password }}
|
||||
|
||||
# Jenkins job URL
|
||||
jenkinsUrl=https://jenkins.verdnatura.es/job/Scheduler/job/db-apply-changes-test
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
[mariabackup]
|
||||
host = localhost
|
||||
user = {{ user_mariabackup }}
|
||||
password = {{ password_user_mariabackup }}
|
||||
user = {{ mariabackupusernametpl }}
|
||||
password = {{ mariabackuppasstpl }}
|
||||
use-memory = 1G
|
||||
parallel = 2
|
||||
stream = mbstream
|
Loading…
Reference in New Issue