Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge "Backup&Restore Snapshots RFE"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Apr 30, 2021
2 parents c4752cd + ebcfee5 commit b46a9f5
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 136 deletions.
19 changes: 0 additions & 19 deletions tripleo_ansible/roles/backup_and_restore/tasks/db_backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,3 @@
tags:
- bar_create_recover_image
no_log: "{{ tripleo_backup_and_restore_hide_sensitive_logs | bool }}"

- name: Pause mysql.
command: "{{ tripleo_container_cli }} pause {{ tripleo_backup_and_restore_mysql_container }}"
when:
- mysql_password.stderr is defined
- tripleo_backup_and_restore_mysql_container == "mysql"
- not enabled_galera
- tripleo_backup_and_restore_service_manager|bool
tags:
- bar_create_recover_image

- name: Stop pacemaker
command: pcs cluster stop --all
when:
- enabled_galera
- tripleo_backup_and_restore_service_manager|bool
run_once: true
tags:
- bar_create_recover_image
26 changes: 10 additions & 16 deletions tripleo_ansible/roles/backup_and_restore/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,15 @@
- name: Setup ReaR
import_tasks: setup_rear.yml

- name: Service management
import_tasks: service_manager_pause.yml
when:
- tripleo_backup_and_restore_service_manager
- name: Do Backup
block:
- name: Backup the database
import_tasks: db_backup.yml

- name: Backup the database
import_tasks: db_backup.yml
- name: Backup pacemaker configuration
import_tasks: pacemaker_backup.yml

- name: Backup pacemaker configuration
import_tasks: pacemaker_backup.yml

- name: Create recovery images with ReaR
import_tasks: run_backup.yml

- name: Service management
import_tasks: service_manager_unpause.yml
when:
- tripleo_backup_and_restore_service_manager
- name: Create recovery images with ReaR
import_tasks: run_backup.yml
tags:
- bar_create_recover_image
45 changes: 45 additions & 0 deletions tripleo_ansible/roles/backup_and_restore/tasks/run_backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,35 @@
tags:
- always

- name: Move virtual IPs to another node before stopping pacemaker
when: pacemaker_enabled
shell: |
CLUSTER_NODE=$(crm_node -n)
echo "Retrieving all the VIPs which are hosted on this node"
VIPS_TO_MOVE=$(crm_mon --as-xml | xmllint --xpath '//resource[@resource_agent = "ocf::heartbeat:IPaddr2" and @role = "Started" and @managed = "true" and ./node[@name = "'${CLUSTER_NODE}'"]]/@id' - | sed -e 's/id=//g' -e 's/"//g')
for v in ${VIPS_TO_MOVE}; do
echo "Moving VIP $v on another node"
pcs resource ban $v ${CLUSTER_NODE} --wait=300
done
echo "Removing the location constraints that were created to move the VIPs"
for v in ${VIPS_TO_MOVE}; do
echo "Removing location ban for VIP $v"
ban_id=$(cibadmin --query | xmllint --xpath 'string(//rsc_location[@rsc="'${v}'" and @node="'${CLUSTER_NODE}'" and @score="-INFINITY"]/@id)' -)
if [ -n "$ban_id" ]; then
pcs constraint remove ${ban_id}
else
echo "Could not retrieve and clear location constraint for VIP $v" 2>&1
fi
done
tags:
- bar_create_recover_image

- name: Take this node out of pacemaker
command: pcs node standby
when: pacemaker_enabled
tags:
- bar_create_recover_image

- name: Create the node backup
become: true
command: rear {{ '-s ' if tripleo_backup_and_restore_rear_simulate else '' }}-d -v mkbackup
Expand All @@ -45,3 +74,19 @@
var: tripleo_backup_and_restore_rear_output
tags:
- bar_create_recover_image

- name: Add the node to the pacemaker cluster
command: pcs node unstandby
when: pacemaker_enabled
tags:
- bar_create_recover_image

- name: Wait until pacemaker has Galera up&running
shell: netstat -tunlp | grep ":3306 " | sed -e 's/.*\///'
register: mysql_result
retries: 10
until: mysql_result is search('mysqld')
delay: 5
when: pacemaker_enabled
tags:
- bar_create_recover_image

This file was deleted.

This file was deleted.

0 comments on commit b46a9f5

Please sign in to comment.