Automate the /var/lib/ceph backup during recovery phase
To keep strong consistency for Ceph when Ceph nodes are collocated with
controllers, it is necessary to take a backup of the /var/lib/ceph
directory just before doing a recovery, restore the ReaR backup and then
extract the /var/lib/ceph backup over the (old) ceph data that is
outdated. With this simple action, the information lost is almost none.
This change creates two new scripts that are executed by ReaR during
restore that do exactly what is needed, eliminating the need for doing
it by hand.
Change-Id: Ib7c699b737980c5495cce2cf42f5847fda0f72f5
(cherry picked from commit 288233da8c
)
This commit is contained in:
parent
553f361e21
commit
55f6609c6f
@ -141,3 +141,64 @@
|
||||
when: sftp_backup
|
||||
tags:
|
||||
- bar_setup_rear
|
||||
|
||||
- name: Is this machine a ceph node?
|
||||
stat:
|
||||
path: /var/lib/ceph
|
||||
register: varlibceph_dir
|
||||
tags:
|
||||
- bar_setup_rear
|
||||
|
||||
- name: Get the directory where /var/lib/ceph is mounted on
|
||||
shell: |
|
||||
set -o pipefail
|
||||
df /var/lib/ceph | grep -v Filesystem | awk '{print $6}'
|
||||
register: tripleo_backup_and_restore_ceph_dir
|
||||
when: varlibceph_dir.stat.exists
|
||||
tags:
|
||||
- bar_setup_rear
|
||||
|
||||
- name: Get the device where /var/lib/ceph is mounted on
|
||||
shell: |
|
||||
set -o pipefail
|
||||
df /var/lib/ceph | grep -v Filesystem | awk '{print $1}'
|
||||
register: tripleo_backup_and_restore_ceph_device
|
||||
when: varlibceph_dir.stat.exists
|
||||
tags:
|
||||
- bar_setup_rear
|
||||
|
||||
- name: Get the filesystem format of the device where /var/lib/ceph is mounted on
|
||||
shell: |
|
||||
set -o pipefail
|
||||
grep {{ tripleo_backup_and_restore_ceph_device.stdout }} /etc/mtab | grep '{{ tripleo_backup_and_restore_ceph_dir.stdout }} ' | awk '{print $3}'
|
||||
register: tripleo_backup_and_restore_ceph_device_format
|
||||
when: varlibceph_dir.stat.exists
|
||||
tags:
|
||||
- bar_setup_rear
|
||||
|
||||
- name: Program a script that will trigger during restore backuping /var/lib/ceph if it exists just before restore
|
||||
copy:
|
||||
dest: /usr/share/rear/setup/default/011_backup_ceph.sh
|
||||
content: |
|
||||
echo "Taking a fresh ceph data backup if this controller has co-located cephs"
|
||||
mount -t {{ tripleo_backup_and_restore_ceph_device_format.stdout }} {{ tripleo_backup_and_restore_ceph_device.stdout }} /mnt/local
|
||||
cd /mnt/local
|
||||
[ -d "var/lib/ceph" ] && tar cvfz /tmp/ceph.tar.gz var/lib/ceph --xattrs --xattrs-include='*.*' --acls
|
||||
cd /
|
||||
umount {{ tripleo_backup_and_restore_ceph_device.stdout }}
|
||||
when: varlibceph_dir.stat.exists
|
||||
tags:
|
||||
- bar_setup_rear
|
||||
|
||||
- name: Program a script that will trigger during restoration to restore /var/lib/ceph backup after a full recovery
|
||||
copy:
|
||||
dest: /usr/share/rear/wrapup/default/501_restore_ceph.sh
|
||||
content: |
|
||||
echo "Restoring ceph backup if it exists"
|
||||
if [ -f "/tmp/ceph.tar.gz" ]; then
|
||||
rm -rf /mnt/local/var/lib/ceph/*
|
||||
tar xvC /mnt/local -f /tmp/ceph.tar.gz var/lib/ceph --xattrs --xattrs-include='*.*'
|
||||
fi
|
||||
when: varlibceph_dir.stat.exists
|
||||
tags:
|
||||
- bar_setup_rear
|
||||
|
Loading…
Reference in New Issue
Block a user