Pacemaker backup task
This patch add task for backing up pacemaker configuration and makes existing mysql backup task a bit more configurable. Change-Id: I67b1991daf617093ec59efea5062157d59106bd4
This commit is contained in:
parent
80d973f0bb
commit
655d4ea9fe
|
@ -67,6 +67,15 @@ If using Docker:
|
|||
| `operations_custom_service_map` | `{}` | Dictionary of services and their systemd unit files, container names, and vhosts. This will be combined with the builtin list of services in `vars/main.yml`. |
|
||||
|
||||
|
||||
**Variables for backup**
|
||||
|
||||
| Name | Default Value | Description |
|
||||
|-------------------|---------------------|----------------------|
|
||||
| `backup_tmp_dir` | `/var/tmp/openstack-backup` | Temporary directory created on host to store backed up data. |
|
||||
| `backup_directory` | `/home/{{ ansible_user }}` | Directory on backup host where backup archive will be saved. |
|
||||
| `backup_host` | `{{ hostvars[groups[backup_server_hostgroup][0]]['inventory_hostname'] }}` | Backup host where data will be archived.|
|
||||
| `backup_host_ssh_args` | `-F /var/tmp/{{ ansible_hostname }}_config` | ssh arguments used for connectiong to backup host. |
|
||||
|
||||
## Dependencies ##
|
||||
|
||||
None
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
# to licensing conflicts. But we sill need to be able to pull them in for
|
||||
# lint checks and want to document these as ansible specific things that may
|
||||
# be required for this repository.
|
||||
ansible
|
||||
ansible==2.7.6
|
||||
ansible-lint
|
||||
|
|
|
@ -26,3 +26,10 @@ operations_logs:
|
|||
# Restart Service
|
||||
operations_services_to_restart: []
|
||||
operations_custom_service_map: {}
|
||||
|
||||
|
||||
# Backup
|
||||
backup_tmp_dir: /var/tmp/openstack-backup
|
||||
backup_directory: "/home/{{ ansible_user }}"
|
||||
backup_host: "{{ hostvars[groups[backup_server_hostgroup][0]]['inventory_hostname'] }}"
|
||||
backup_host_ssh_args: "-F /var/tmp/{{ ansible_hostname }}_config"
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
- name: Remove any existing database backup directory
|
||||
file:
|
||||
path: /var/tmp/openstack-backup/mysql
|
||||
path: "{{ backup_tmp_dir }}/mysql"
|
||||
state: absent
|
||||
|
||||
- name: Create a new MySQL database backup directory
|
||||
file:
|
||||
path: /var/tmp/openstack-backup/mysql
|
||||
path: "{{ backup_tmp_dir }}/mysql"
|
||||
state: directory
|
||||
|
||||
- name: Get the database root password
|
||||
|
@ -33,29 +33,29 @@
|
|||
- name: Create MySQL backup script
|
||||
template:
|
||||
src: backup_mysql.sh.j2
|
||||
dest: /var/tmp/openstack-backup/mysql/backup_mysql.sh
|
||||
dest: "{{ backup_tmp_dir }}/mysql/backup_mysql.sh"
|
||||
mode: u+rwx
|
||||
|
||||
- name: Run the MySQL backup script
|
||||
command: /var/tmp/openstack-backup/mysql/backup_mysql.sh
|
||||
command: "{{ backup_tmp_dir }}/mysql/backup_mysql.sh"
|
||||
|
||||
# The archive module is pretty limited. Using a script instead.
|
||||
- name: Archive the OpenStack databases
|
||||
script: |
|
||||
/bin/tar --ignore-failed-read --xattrs \
|
||||
-zcf /var/tmp/openstack-backup/mysql/openstack-backup-mysql.tar \
|
||||
/var/tmp/openstack-backup/mysql/*.sql
|
||||
-zcf {{ backup_tmp_dir }}/mysql/openstack-backup-mysql.tar \
|
||||
{{ backup_tmp_dir }}/mysql/*.sql
|
||||
|
||||
- name: Copy the archive to the backup server
|
||||
synchronize:
|
||||
mode: pull
|
||||
src: "/var/tmp/openstack-backup/mysql/openstack-backup-mysql.tar"
|
||||
dest: "{{ backup_directory | default('~/.') }}"
|
||||
src: "{{ backup_tmp_dir }}/mysql/openstack-backup-mysql.tar"
|
||||
dest: "{{ backup_directory }}"
|
||||
set_remote_user: false
|
||||
ssh_args: "-F /var/tmp/{{ ansible_hostname }}_config"
|
||||
delegate_to: "{{ hostvars[groups[backup_server_hostgroup][0]]['inventory_hostname'] }}"
|
||||
ssh_args: "{{ backup_host_ssh_args }}"
|
||||
delegate_to: "{{ backup_host }}"
|
||||
|
||||
- name: Remove the database backup directory
|
||||
file:
|
||||
path: /var/tmp/openstack-backup/mysql
|
||||
path: "{{ backup_tmp_dir }}/mysql"
|
||||
state: absent
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Tasks for backing up Pacemaker configuration
|
||||
|
||||
- name: Remove any existing Pacemaker backup directory
|
||||
file:
|
||||
path: "{{ backup_tmp_dir }}/pcs"
|
||||
state: absent
|
||||
|
||||
- name: Create a new Pacemaker backup directory
|
||||
file:
|
||||
path: "{{ backup_tmp_dir }}/pcs"
|
||||
state: directory
|
||||
|
||||
- name: Create Pacemaker backup script
|
||||
template:
|
||||
src: backup_pacemaker.sh.j2
|
||||
dest: "{{ backup_tmp_dir }}/pcs/backup_pacemaker.sh"
|
||||
mode: u+rwx
|
||||
|
||||
- name: Run the Pacemaker backup script
|
||||
command: "{{ backup_tmp_dir }}/pcs/backup_pacemaker.sh"
|
||||
|
||||
- name: Archive the Pacemaker configuration
|
||||
script: |
|
||||
/bin/tar --ignore-failed-read --xattrs \
|
||||
-zcf {{ backup_tmp_dir }}/pcs/openstack-backup-pacemaker.tar \
|
||||
{{ backup_tmp_dir }}/pcs/cib.xml \
|
||||
{{ backup_tmp_dir }}/pcs/pacemaker_backup.tar.bz2
|
||||
|
||||
- name: Copy the archive to the backup server
|
||||
synchronize:
|
||||
mode: pull
|
||||
src: "{{ backup_tmp_dir }}/pcs/openstack-backup-pacemaker.tar"
|
||||
dest: "{{ backup_directory }}"
|
||||
set_remote_user: false
|
||||
ssh_args: "{{ backup_host_ssh_args }}"
|
||||
delegate_to: "{{ backup_host }}"
|
||||
|
||||
- name: Remove the database backup directory
|
||||
file:
|
||||
path: "{{ backup_tmp_dir }}/pcs"
|
||||
state: absent
|
|
@ -16,4 +16,4 @@
|
|||
- name: Make sure the backup directory exists
|
||||
file:
|
||||
path: "{{ backup_directory }}"
|
||||
state: directory
|
||||
state: directory
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
mysql -uroot -p{{ mysql_root_password }} -s -N -e "select distinct table_schema from information_schema.tables where engine='innodb' and table_schema != 'mysql';" | xargs mysqldump -uroot -p{{ mysql_root_password }} --single-transaction --databases > /var/tmp/openstack-backup/mysql/openstack-backup-mysql.sql
|
||||
mysql -uroot -p{{ mysql_root_password }} -s -N -e "select distinct table_schema from information_schema.tables where engine='innodb' and table_schema != 'mysql';" | xargs mysqldump -uroot -p{{ mysql_root_password }} --single-transaction --databases > {{ backup_tmp_dir }}/mysql/openstack-backup-mysql.sql
|
||||
|
||||
mysql -uroot -p{{ mysql_root_password }} -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_root_password }} -s -N -e | sed 's/$/;/' > /var/tmp/openstack-backup/mysql/openstack-backup-mysql-grants.sql
|
||||
mysql -uroot -p{{ mysql_root_password }} -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_root_password }} -s -N -e | sed 's/$/;/' > {{ backup_tmp_dir }}/mysql/openstack-backup-mysql-grants.sql
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
pushd {{ backup_tmp_dir }}/pcs
|
||||
pcs cluster cib cib.xml
|
||||
pcs config backup pacemaker_backup
|
||||
popd
|
Loading…
Reference in New Issue