Add playbook to perform UC DB backup only.
Currently, the openstack undercloud backup command allows us setting
up rear, nfs and run the Undercloud's backup. However, it might be
useful to just perform a DB backup instead of a full backup of the
Undercloud.
This patch adds a new playbook cli-undercloud-db-backup.yaml which
invokes only the db_backup.yml play from the backup_and_restore
role. This will perform only the MariaDB database backup for the
Undercloud node. As the file name was hardcoded in the play, this
patch also parametrizes it so that it will be possible to run
the command multiple times without override an existing backup.
Related: rhbz#1977392
Change-Id: I62cadfd95c514edf0b982fa652a53feadb24f2b7
(cherry picked from commit 0f221aca95
)
This commit is contained in:
parent
8398ce3a82
commit
3791391e6e
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
# Copyright 2020 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: TripleO Undercloud DB backup.
|
||||
hosts: Undercloud
|
||||
remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}"
|
||||
become: true
|
||||
tasks:
|
||||
- name: Create DB Backup for the undercloud
|
||||
vars:
|
||||
tripleo_backup_and_restore_service_manager: false
|
||||
tripleo_backup_and_restore_mysql_backup_file: "/home/stack/openstack-backup-mysql-{{ lookup('pipe', 'date +%F_%H_%M_%S') }}.sql"
|
||||
tripleo_backup_and_restore_mysql_grants_file: "/home/stack/openstack-backup-mysql-grants-{{ lookup('pipe', 'date +%F_%H_%M_%S') }}.sql"
|
||||
include_role:
|
||||
name: backup_and_restore
|
||||
tasks_from: db_backup.yml
|
|
@ -31,6 +31,12 @@ tripleo_backup_and_restore_enable_snapshots: true
|
|||
# Set the name of the mysql container
|
||||
tripleo_backup_and_restore_mysql_container: mysql
|
||||
|
||||
# Default name for the Undercloud mysql DB backup file
|
||||
tripleo_backup_and_restore_mysql_backup_file: "openstack-backup-mysql.sql"
|
||||
|
||||
# Default name for the Undercloud mysql DB grants file
|
||||
tripleo_backup_and_restore_mysql_grants_file: "openstack-backup-mysql-grants.sql"
|
||||
|
||||
# All variables within this role should have a prefix of "tripleo_backup_and_restore"
|
||||
# By default this should be the Undercloud node
|
||||
tripleo_backup_and_restore_nfs_server: 192.168.24.1
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
-p{{ mysql_password.stdout }} -s -N \
|
||||
-e \"SELECT CONCAT('\\\"SHOW GRANTS FOR ''',user,'''@''',host,''';\\\"') \
|
||||
FROM mysql.user where (length(user) > 0 and user NOT LIKE 'root')\" | xargs -n1 mysql \
|
||||
-uroot -p{{ mysql_password.stdout }} -s -N -e | sed 's/$/;/' " > openstack-backup-mysql-grants.sql
|
||||
-uroot -p{{ mysql_password.stdout }} -s -N -e | sed 's/$/;/' " > {{ tripleo_backup_and_restore_mysql_grants_file }}
|
||||
when: mysql_password.stderr is defined
|
||||
tags:
|
||||
- bar_create_recover_image
|
||||
|
@ -118,7 +118,7 @@
|
|||
-p{{ mysql_password.stdout }} -s -N \
|
||||
-e \"select distinct table_schema from information_schema.tables \
|
||||
where engine='innodb' and table_schema != 'mysql';\" | xargs mysqldump -uroot \
|
||||
-p{{ mysql_password.stdout }} --single-transaction --databases" > openstack-backup-mysql.sql
|
||||
-p{{ mysql_password.stdout }} --single-transaction --databases" > {{ tripleo_backup_and_restore_mysql_backup_file }}
|
||||
when: mysql_password.stderr is defined
|
||||
tags:
|
||||
- bar_create_recover_image
|
||||
|
|
Loading…
Reference in New Issue