Openstack Cinder Ceph(RBD) backup recovery process (backup/restore)

Keywords: OpenStack snapshot

Summary:

In this section, we discuss the openstack cinder volume rbd-driven backup/restore operation.

Backup is a backup of volume s elsewhere (backup devices) that can be restore d in the future.

Backup VS Snapshot

Both Backup and snapshot can save the current state of the volume for later recovery.However, there are differences in their usage and implementation, which are manifested in:

  • Snapshot depends on the source volume and cannot exist independently; backup does not depend on the source volume and can restore even if the source volume does not exist.
  • Snapshot and source volume are usually stored together and managed by the same volume provider; while backup is stored in a separate backup device and has its own backup scheme and implementation, regardless of volume provider.

These two points determine that backup has disaster tolerance; snapshot provides easy backtracking within the volume provider.

A RBD Incremental Backup and Recovery Principle

1 Create cloud disk test_volume 1, size=1G
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd create volumes/test_volume1 --size 1G
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l volumes
NAME         SIZE PARENT FMT PROT LOCK 
test_volume1 1GiB          2         
2 Create test_volume 1 snapshots t1 and t2
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd snap create volumes/test_volume1@test.snap.t1
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l volumes
NAME                      SIZE PARENT FMT PROT LOCK 
test_volume1              1GiB          2           
test_volume1@test.snap.t1 1GiB          2           
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd snap create volumes/test_volume1@test.snap.t2
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l volumes
NAME                      SIZE PARENT FMT PROT LOCK 
test_volume1              1GiB          2           
test_volume1@test.snap.t1 1GiB          2           
test_volume1@test.snap.t2 1GiB          2           
()[root@busybox-openstack-5c687fdc9-mpwjd /]# 
3 Create incremental diff
# diff from initial to t1
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd export-diff volumes/test_volume1@test.snap.t1 diff_t1_between_initial
Exporting image: 100% complete...done.
# diff from initial to t2
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd export-diff volumes/test_volume1@test.snap.t2 diff_t2_between_initial
Exporting image: 100% complete...done.
# diff from t1 to t2
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd export-diff --from-snap test.snap.t1 volumes/test_volume1@test.snap.t2  diff_t1_between_t2
Exporting image: 100% complete...done.
()[root@busybox-openstack-5c687fdc9-mpwjd /]# ls -l |grep diff
-rw-r--r--     1 root root    39 Sep  4 10:52 diff_t1_between_initial
-rw-r--r--     1 root root    56 Sep  4 10:52 diff_t1_between_t2
-rw-r--r--     1 root root    39 Sep  4 10:52 diff_t2_between_initial
4 Create backups by incremental diff
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd create backups/backup_image --size 1G
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l backups
NAME         SIZE PARENT FMT PROT LOCK 
backup_image 1GiB          2    
# import diff from initial to t1
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd import-diff diff_t1_between_initial backups/backup_image
Importing image diff: 100% complete...done.
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l backups
NAME                      SIZE PARENT FMT PROT LOCK 
backup_image              1GiB          2           
backup_image@test.snap.t1 1GiB          2   
# import diff from t1 to t2
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd import-diff diff_t1_between_t2 backups/backup_image
Importing image diff: 100% complete...done.
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l backups
NAME                      SIZE PARENT FMT PROT LOCK 
backup_image              1GiB          2           
backup_image@test.snap.t1 1GiB          2           
backup_image@test.snap.t2 1GiB          2  

When backing up 2ceph:

1. Create a cloud disk volume-id of 1G
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd create volumes/volume-id --size 1G
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd ls -l volumes |grep volume-id
volume-id         1GiB                          2           
2. Try diff store first to create a base disk in backups
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd create backups/volume-volume-id.backup.base --size 1G
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd ls -l backups
NAME                         SIZE PARENT FMT PROT LOCK 
volume-volume-id.backup.base 1GiB          2           
3. Create volume-id snapshot 1 with the following naming rules
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd snap  create volumes/volume-id@backup.backup-id.snap.time1
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd ls -l volumes |grep volume-id
volume-id                                 1GiB                       2           
volume-id@backup.backup-id.snap.time1     1GiB                       2           
4. Difference between Export Cloud Disk and Snapshot 1 1
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd export-diff volumes/volume-id@backup.backup-id.snap.time1 test_diff_snap_time1
Exporting image: 100% complete...done.
()[root@busybox-openstack-f7bcf88-hgdkz /]# ls
test_diff_snap_time1 
5. Import Difference 1 into the base disk of backups, where the base disk generates a snapshot
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd import-diff test_diff_snap_time1 backups/volume-volume-id.backup.base
Importing image diff: 100% complete...done.
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd ls -l backups
NAME                                                     SIZE PARENT FMT PROT LOCK 
volume-volume-id.backup.base                             1GiB          2           
volume-volume-id.backup.base@backup.backup-id.snap.time1 1GiB          2           
6. Create a new volume-id snapshot the second time you do an incremental backup 2
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd snap  create volumes/volume-id@backup.backup-id2.snap.time2
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd ls -l backups
NAME                                                     SIZE PARENT FMT PROT LOCK 
volume-volume-id.backup.base                             1GiB          2           
volume-volume-id.backup.base@backup.backup-id.snap.time1 1GiB          2           
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd ls -l volumes |grep volume-id
volume-id                                                                                     1GiB                                                                                                        2           
volume-id@backup.backup-id.snap.time1                                                         1GiB                                                                                                        2           
volume-id@backup.backup-id2.snap.time2                                                        1GiB                                                                                                        2           
7. Difference between exported snapshot 1 and snapshot 2 2
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd export-diff --snap backup.backup-id.snap.time1 volumes/volume-id@backup.backup-id2.snap.time2 test_diff_snap_time1_time2
Exporting image: 100% complete...done.
8. Import Difference 2 into the base disk of backups, and the base disk generates a new snapshot
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd import-diff test_diff_snap_time1_time2 backups/volume-volume-id.backup.base
Importing image diff: 100% complete...done.
()[root@busybox-openstack-f7bcf88-hgdkz /]# rbd ls -l backups
NAME                                                      SIZE PARENT FMT PROT LOCK 
volume-volume-id.backup.base                              1GiB          2           
volume-volume-id.backup.base@backup.backup-id.snap.time1  1GiB          2           
volume-volume-id.backup.base@backup.backup-id2.snap.time2 1GiB          2           
9. Delete snapshot 1 of volume-id
10. If there is an exception to the diff store, it will be backed up through the full store by copying the cloud disk in chunk=128M fragments to the new cloud disk.
11. Back up metadata

Implementation of three RBD recovery backup:

1 Check to see if diff restore is satisfied first, the following conditions need to be met
check can  diff restore:
1 base exist: backups/volume-volume-id.backup.base
2 restore point snapshot exist: backups/volume-volume-id.backup.base@backup.backup-id.snap.time1
3 volume file is rbd
4 backup[volume_id] !=  new volume_id
5 rbd volume has no extents (extend)
2. If the diff restore condition is satisfied, export the difference of the corresponding backup-id first
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd export-diff  backups/volume-volume-id.backup.base@backup.backup-id1.snap.time1 test_diff_backup_id2
Exporting image: 100% complete...done.
3. Import the difference of the corresponding backup-id into the new-volume-id
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd import-diff test_diff_backup_id2 volumes/new-volume-id
Importing image diff: 100% complete...done.
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l volumes
NAME                                       SIZE PARENT FMT PROT LOCK 
new-volume-id                              1GiB          2           
new-volume-id@backup.backup-id1.snap.time1 1GiB          2           
volume-id                                  1GiB          2           
volume-id@backup.backup-id1.snap.time1     1GiB          2           
4. If the size of the new volume is inconsistent with the size of the backup, resize is required after importing the differences.
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd create volumes/new-volume-id2 --size 2G
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd import-diff test_diff_backup_id2 volumes/new-volume-id2
Importing image diff: 100% complete...done.
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l volumes
NAME                                        SIZE PARENT FMT PROT LOCK 
new-volume-id                               1GiB          2           
new-volume-id@backup.backup-id1.snap.time1  1GiB          2           
new-volume-id2                              1GiB          2           
new-volume-id2@backup.backup-id1.snap.time1 1GiB          2           
volume-id                                   1GiB          2           
volume-id@backup.backup-id1.snap.time1      1GiB          2           
()[root@busybox-openstack-5c687fdc9-mpwjd /]# 
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd resize volumes/new-volume-id2 --size 2G
Resizing image: 100% complete...done.
()[root@busybox-openstack-5c687fdc9-mpwjd /]# rbd ls -l volumes
NAME                                        SIZE PARENT FMT PROT LOCK 
new-volume-id                               1GiB          2           
new-volume-id@backup.backup-id1.snap.time1  1GiB          2           
new-volume-id2                              2GiB          2           
new-volume-id2@backup.backup-id1.snap.time1 1GiB          2           
volume-id                                   1GiB          2           
volume-id@backup.backup-id1.snap.time1      1GiB          2           
5. If the diff restore condition is not met or if an exception occurs during the diff restore process, full restore is performed by copying the cloud disk into a new cloud disk in chunk=128M fragments.
6. Restore Metadata

Posted by Cantaloupe on Mon, 23 Sep 2019 19:13:26 -0700