Blame SOURCES/rear-bz1743303-rubrik.patch

a63dfb
From 9a2e5bf96df70883fc5978471f72d6bd697116e0 Mon Sep 17 00:00:00 2001
a63dfb
From: Damani <damani@rubrik.com>
a63dfb
Date: Thu, 26 Sep 2019 08:27:53 -0600
a63dfb
Subject: [PATCH] Support for Rubrik
a63dfb
a63dfb
---
a63dfb
 .gitignore                                    |   3 +
a63dfb
 doc/user-guide/16-Rubrik-CDM.adoc             | 106 ++++++++++++++++++
a63dfb
 usr/share/rear/conf/default.conf              |  11 ++
a63dfb
 .../rear/prep/CDM/default/400_prep_cdm.sh     |   7 ++
a63dfb
 .../prep/CDM/default/450_check_cdm_client.sh  |  13 +++
a63dfb
 .../CDM/default/400_restore_with_cdm.sh       |  19 ++++
a63dfb
 .../410_use_replica_cdm_cluster_cert.sh       |  43 +++++++
a63dfb
 .../CDM/default/430_gen_rbs_uuid_for_cdm.sh   |  29 +++++
a63dfb
 .../verify/CDM/default/450_start_cdm_rbs.sh   |  17 +++
a63dfb
 9 files changed, 248 insertions(+)
a63dfb
 create mode 100644 doc/user-guide/16-Rubrik-CDM.adoc
a63dfb
 create mode 100644 usr/share/rear/prep/CDM/default/400_prep_cdm.sh
a63dfb
 create mode 100644 usr/share/rear/prep/CDM/default/450_check_cdm_client.sh
a63dfb
 create mode 100644 usr/share/rear/restore/CDM/default/400_restore_with_cdm.sh
a63dfb
 create mode 100644 usr/share/rear/verify/CDM/default/410_use_replica_cdm_cluster_cert.sh
a63dfb
 create mode 100644 usr/share/rear/verify/CDM/default/430_gen_rbs_uuid_for_cdm.sh
a63dfb
 create mode 100644 usr/share/rear/verify/CDM/default/450_start_cdm_rbs.sh
a63dfb
a63dfb
diff --git a/.gitignore b/.gitignore
a63dfb
index 5e3dc940..a644c865 100644
a63dfb
--- a/.gitignore
a63dfb
+++ b/.gitignore
a63dfb
@@ -4,3 +4,6 @@
a63dfb
 build-stamp
a63dfb
 /var
a63dfb
 /etc/rear/site.conf
a63dfb
+.DS_Store
a63dfb
+.vscode
a63dfb
+servers
a63dfb
diff --git a/doc/user-guide/16-Rubrik-CDM.adoc b/doc/user-guide/16-Rubrik-CDM.adoc
a63dfb
new file mode 100644
a63dfb
index 00000000..41f37d20
a63dfb
--- /dev/null
a63dfb
+++ b/doc/user-guide/16-Rubrik-CDM.adoc
a63dfb
@@ -0,0 +1,106 @@
a63dfb
+= Documentation for the Rubrik Cloud Data Management (CDM) Backup and Restore Method
a63dfb
+
a63dfb
+== Summary
a63dfb
+
a63dfb
+The Rubrik CDM backup and restore method for ReaR allows Rubrik CDM to perform bare metal recovery of Linux systems that are supported by ReaR. It does this by including the installed Rubrik CDM RBS agent files in the ISO that is created by `rear mkrescue` via a pre-script in the fileset. The ISO is left in place under `/var/lib/rear/output/rear-<hostname>.iso` by default. During the fileset backup Rubrik will backup the main operating system files as well as the ReaR ISO file. 
a63dfb
+
a63dfb
+Bare Metal Recovery is performed by first restoring the ReaR ISO file from Rubrik CDM to an alternate host. Next the host being restored is booted from the ISO via CD/DVD, USB, vSphere Datastore ISO, etc... Once booted running `rear recover` will prepare the host for restore and start the Rubrik CDM RBS agent. If the host has a new IP address the new RBS agent will need to be registered with the Rubrik cluster. Registration is not necessary if the recovery host is reusing the same IP address as the original. All of the files for the host are then recovered from Rubrik CDM to the recovery host's `/mnt/local` directory by the user. Once complete the user exit's ReaR and reboots the host. 
a63dfb
+
a63dfb
+== Configuration
a63dfb
+
a63dfb
+1. Install and configure ReaR in accordance with:
a63dfb
+- Red Hat 
a63dfb
+   * https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/ch-relax-and-recover_rear
a63dfb
+- Ubuntu
a63dfb
+   * http://manpages.ubuntu.com/manpages/disco/en/man8/rear.8.html
a63dfb
+- SUSE
a63dfb
+   * https://en.opensuse.org/SDB:Disaster_Recovery
a63dfb
+   * https://documentation.suse.com/sle-ha/15-SP1/html/SLE-HA-all/cha-ha-rear.html
a63dfb
+- Generic
a63dfb
+   * https://github.com/rear/rear
a63dfb
+
a63dfb
+   NOTE: Ignore any instructions to configure external storage like NFS, CIFS/SMB or ftp. Also ignore any instructions to configure a specific backup method. This will be taken care of in the next steps. 
a63dfb
+
a63dfb
+   NOTE: Ignore any instructions to schedule ReaR to run via the host based scheduler (cron). Rubrik CDM will run ReaR via a pre-script in the fileset. If this is not preferred ReaR can be scheduled on the host, however, the ISOs created may not be in sync with the backups.
a63dfb
+
a63dfb
+   NOTE: If installing the pre-release or development version for which there is no installer, copy the repo to the host being protected. Then run `make install` from its root directory of the repo. 
a63dfb
+
a63dfb
+1. Install the Rubrik CDM RBS agent as directed by the Rubrik documentation.
a63dfb
+1. Edit `/etc/rear/local.conf` and enter:
a63dfb
+
a63dfb
+   OUTPUT=ISO
a63dfb
+   BACKUP=CDM
a63dfb
+
a63dfb
+1. Test `ReaR` by running `rear -v mkrescue`
a63dfb
+1. Configure fileset backup of the host and add `/usr/sbin/rear mkrescue` as a prescript. 
a63dfb
+1. ISOs will be saved as `/var/lib/rear/output/*.iso`
a63dfb
+
a63dfb
+- Recovery 
a63dfb
+
a63dfb
+1. Recover `/var/lib/rear/output/rear-<hostname>.iso` from host to be restored. 
a63dfb
+1. Boot recovery machine using recovered ISO.
a63dfb
+   
a63dfb
+   NOTE: Recovered system will use the same networking as the original machine. Verify no IP conflicts will occur. 
a63dfb
+
a63dfb
+   NOTE: If the same static IP address may be used it will need to be changed if the original machine is still running.
a63dfb
+
a63dfb
+1. Verify Firewall is down on recovery host.
a63dfb
+1. Run `rear recover`
a63dfb
+1. Answer inline questions until `rear>` prompt appears.
a63dfb
+1. Run `ps -eaf` and verify that `backup_agent_main` and `bootstrap_agent_main` are running.
a63dfb
+1. Get the IP address of the system using `ip addr`
a63dfb
+1. Register the new IP with the Rubrik appliance (if needed)
a63dfb
+1. Perform a re-directed export of `/` to `/mnt/local`
a63dfb
+1. Reboot
a63dfb
+1. Recover other file systems as needed.
a63dfb
+
a63dfb
+   Note: that the Rubrik RBS agent will connect as the original machine now. The host may need to be reinstalled and re-registered if the original machine is still running. 
a63dfb
+
a63dfb
+== Known Issues
a63dfb
+
a63dfb
+* Recovery via IPv6 is not yet supported.
a63dfb
+* Automatic recovery from replica CDM cluster is not supported
a63dfb
+* CDM may take some time to recognize that the IP address has moved from one system to another. When restoring using the same IP give CDM up to 10 minutes to recognize that the agent is running on another machine. This usually comes up during testing when the original machine is shutdown but not being restored to. 
a63dfb
+* Recovery from a replica CDM cluster is only supported with CDM v4.2.1 and higher.
a63dfb
+* Care must be taken with SUSE systems on DHCP. They tend to request the same IP as the original host. If this is not the desired behavior the system will have to be adjusted after booting from the ReaR ISO.  
a63dfb
+* If multiple restores are performed using the same temporary IP, the temporary IP must first be deleted from Servers & Apps -> Linux and Unix Servers and re-added upon each reuse.
a63dfb
+* ReaR's `ldd` check of other binaries or libraries may result in libraries not being found. This can generally be fixed by adding the path to those libraries to the `LD_LIBRARY_PATH` variable in `/etc/rear/local.conf`. Do this by adding the following line in `/etc/rear/local.conf`:
a63dfb
++
a63dfb
+  export LD_LIBRARY_PATH-"$LD_LIBRARY_PATH:<path>"
a63dfb
++
a63dfb
+To make CentoOS v7.7 work the following line was needed:
a63dfb
++
a63dfb
+  export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/bind9-export"
a63dfb
++
a63dfb
+To make CentOS v8.0 work the following line was needed:
a63dfb
++
a63dfb
+  export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/bind9-export:/usr/lib64/eog:/usr/lib64/python3.6/site-packages:/usr/lib64/samba:/usr/lib64/firefox"
a63dfb
+
a63dfb
+== Troubleshooting
a63dfb
+
a63dfb
+* Verify that ReaR will recover your system without using the CDM backup and restore method. Most errors are due to configuration with ReaR itself and not Rubrik CDM. Use the default ReaR backup and restore method to test with. 
a63dfb
+* Follow the OS specific configuration guides as mentioned at the beginning of this document. 
a63dfb
+
a63dfb
+== Test Matrix
a63dfb
+
a63dfb
+.Test Matrix
a63dfb
+[%header,format=csv]
a63dfb
+|===
a63dfb
+Operating System,DHCP,Static IP,Virtual,Physical,LVM Root Disk,Plain Root Disk,EXT3,EXT4,XFS,BTRFS,Original Cluster,Replication Cluster
a63dfb
+CentOS 7.3,,pass,Pass,,Pass,,,,Pass,,Pass,
a63dfb
+CentOS 7.6,Pass,,Pass,,Pass,,,,Pass,,Pass,
a63dfb
+CentOS 7.7,Pass,,Pass,Pass,Pass,,,,Pass,,Pass,
a63dfb
+CentOS 8.0,Pass,,Pass,,Pass,,,,Pass,,Pass,
a63dfb
+CentOS 5.11,,,,,,,,,,,,
a63dfb
+CentOS 6.10,,,,,,,,,,,,
a63dfb
+RHEL 7.6,Pass,,Pass,,Pass,,,,,,,
a63dfb
+RHEL 7.4,,,,,,,,,,,,
a63dfb
+RHEL 6.10,,,,,,,,,,,,
a63dfb
+SUSE 11 SP4,,,,,,,,,,,,
a63dfb
+SUSE 12 SP4,Pass (uses same IP as original),,Pass,,,,,,,Pass,Pass,
a63dfb
+Ubuntu 14.04 LTS,,,,,,,,,,,,
a63dfb
+Ubuntu 16.04 LTS,Pass,,,,Pass,,,Pass,,,Pass,
a63dfb
+Ubuntu 17.04 LTS,,,,,,,,,,,,
a63dfb
+|===
a63dfb
+
a63dfb
+* Empty cells indicate that no tests were run.
a63dfb
diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf
a63dfb
index b9f10e89..692e1874 100644
a63dfb
--- a/usr/share/rear/conf/default.conf
a63dfb
+++ b/usr/share/rear/conf/default.conf
a63dfb
@@ -1334,6 +1334,17 @@ LANG_RECOVER=C
a63dfb
 # low-quality master encryption key. For details, see the cryptsetup(8) manual page.
a63dfb
 LUKS_CRYPTSETUP_OPTIONS="--iter-time 2000 --use-random"
a63dfb
 
a63dfb
+##
a63dfb
+# BACKUP=CDM (Rubrik CDM; Cloud Data Managemnt)
a63dfb
+##
a63dfb
+# ReaR support for Rubrik Cloud Data Managment (CDM). 
a63dfb
+# ReaR will copy the Rubrk RBS agent and required OS binaries to its ISO for incluson on boot. 
a63dfb
+# ReaR will start the Rubrik RBS agent when 'rear recover' is run.
a63dfb
+COPY_AS_IS_CDM=( /etc/rubrik /usr/bin/rubrik /var/log/rubrik /etc/pki /usr/lib64 )
a63dfb
+COPY_AS_IS_EXCLUDE_CDM=( /var/log/rubrik/* )
a63dfb
+PROGS_CDM=( /usr/bin/rubrik/backup_agent_main /usr/bin/rubrik/bootstrap_agent_main openssl uuidgen )
a63dfb
+
a63dfb
+
a63dfb
 ##
a63dfb
 # BACKUP=FDRUPSTREAM stuff
a63dfb
 ##
a63dfb
diff --git a/usr/share/rear/prep/CDM/default/400_prep_cdm.sh b/usr/share/rear/prep/CDM/default/400_prep_cdm.sh
a63dfb
new file mode 100644
a63dfb
index 00000000..d3fd11b7
a63dfb
--- /dev/null
a63dfb
+++ b/usr/share/rear/prep/CDM/default/400_prep_cdm.sh
a63dfb
@@ -0,0 +1,7 @@
a63dfb
+#
a63dfb
+# prepare stuff for CDM
a63dfb
+#
a63dfb
+
a63dfb
+COPY_AS_IS=( "${COPY_AS_IS[@]}" "${COPY_AS_IS_CDM[@]}" )
a63dfb
+COPY_AS_IS_EXCLUDE=( "${COPY_AS_IS_EXCLUDE[@]}" "${COPY_AS_IS_EXCLUDE_CDM[@]}" )
a63dfb
+PROGS=( "${PROGS[@]}" "${PROGS_CDM[@]}" fmt )
a63dfb
diff --git a/usr/share/rear/prep/CDM/default/450_check_cdm_client.sh b/usr/share/rear/prep/CDM/default/450_check_cdm_client.sh
a63dfb
new file mode 100644
a63dfb
index 00000000..637fac5f
a63dfb
--- /dev/null
a63dfb
+++ b/usr/share/rear/prep/CDM/default/450_check_cdm_client.sh
a63dfb
@@ -0,0 +1,13 @@
a63dfb
+# 450_check_cdm_client.sh
a63dfb
+# 
a63dfb
+# This script checks if a Rubrik CDM client is installed and running
a63dfb
+#
a63dfb
+
a63dfb
+Log "Backup method is Rubrik (CDM): check backup_agent_main"
a63dfb
+if [ ! -x /usr/bin/rubrik/backup_agent_main ]; then
a63dfb
+    StopIfError 1 "Please install Rubrik (CDM) RBS client software."
a63dfb
+fi
a63dfb
+
a63dfb
+ps ax | grep -v grep | grep backup_agent_main
a63dfb
+StopIfError $? "Rubrik (CDM) RBS backup_agent_main was not running on this client."
a63dfb
+
a63dfb
diff --git a/usr/share/rear/restore/CDM/default/400_restore_with_cdm.sh b/usr/share/rear/restore/CDM/default/400_restore_with_cdm.sh
a63dfb
new file mode 100644
a63dfb
index 00000000..bc4811c4
a63dfb
--- /dev/null
a63dfb
+++ b/usr/share/rear/restore/CDM/default/400_restore_with_cdm.sh
a63dfb
@@ -0,0 +1,19 @@
a63dfb
+# 400_restore_with_cdm.sh
a63dfb
+#
a63dfb
+#
a63dfb
+
a63dfb
+LogPrint "Please start the restore process on the Rubrik (CDM) cluster."
a63dfb
+
a63dfb
+if is_true $CDM_NEW_AGENT_UUID; then
a63dfb
+  LogPrint ""
a63dfb
+  LogPrint "Register the appropriate IP address from this list with Rubrik (CDM):"
a63dfb
+  LogPrint "$( ip addr | grep inet | cut -d / -f 1 | grep -v 127.0.0.1 | grep -v ::1 )"
a63dfb
+  LogPrint ""
a63dfb
+fi
a63dfb
+LogPrint "Make sure all required data is restored to $TARGET_FS_ROOT ."
a63dfb
+LogPrint ""
a63dfb
+LogPrint "Next type 'exit' to continue the recovery."
a63dfb
+LogPrint "Info: You can check the recovery process i.e. with the command 'df'."
a63dfb
+LogPrint ""
a63dfb
+
a63dfb
+rear_shell "Has the restore been completed and are you ready to continue the recovery?"
a63dfb
diff --git a/usr/share/rear/verify/CDM/default/410_use_replica_cdm_cluster_cert.sh b/usr/share/rear/verify/CDM/default/410_use_replica_cdm_cluster_cert.sh
a63dfb
new file mode 100644
a63dfb
index 00000000..7f18f27a
a63dfb
--- /dev/null
a63dfb
+++ b/usr/share/rear/verify/CDM/default/410_use_replica_cdm_cluster_cert.sh
a63dfb
@@ -0,0 +1,43 @@
a63dfb
+# 410_use_replica_cdm_cluster_cert.sh
a63dfb
+# If restoring from a replica Rubrik (CDM) cluster use it's cert for RBS.
a63dfb
+
a63dfb
+CDM_RBA_DIR=/etc/rubrik
a63dfb
+CDM_KEYS_DIR=${CDM_RBA_DIR}/keys
a63dfb
+
a63dfb
+# When USER_INPUT_CDM_REPLICA_CLUSTER has any 'true' value be liberal in what you accept and assume exactly 'y' was actually meant:
a63dfb
+LogPrint ""
a63dfb
+is_true "$USER_INPUT_CDM_REPLICA_CLUSTER" && USER_INPUT_CDM_REPLICA_CLUSTER="y"
a63dfb
+while true ; do
a63dfb
+    # Find out if the restore is being done from the original CDM cluster or a Replica
a63dfb
+    # the default (i.e. the automated response after the timeout) should be 'n':
a63dfb
+    answer="$( UserInput -I CDM_REPLICA_CLUSTER -p "Is the data being restored from the original CDM Cluster? (y/n)" -D 'y' -t 300 )"
a63dfb
+    is_true "$answer" && return 0
a63dfb
+    if is_false "$answer" ; then
a63dfb
+        break
a63dfb
+    fi
a63dfb
+    UserOutput "Please answer 'y' or 'n'"
a63dfb
+done
a63dfb
+
a63dfb
+while true; do
a63dfb
+    CDM_CLUSTER_IP="$(UserInput -I USER_INPUT_CDM_CLUSTER_IP -r -t 0 -p "Enter one of the IP addresses for the replica CDM cluster: ")"
a63dfb
+    [[ -n "$CDM_CLUSTER_IP" ]] && break
a63dfb
+    PrintError "Please enter a non-empty CDM cluster IP."
a63dfb
+done
a63dfb
+
a63dfb
+CDM_SUNOS_TAR=rubrik-agent-sunos5.10.sparc.tar.gz
a63dfb
+cd /tmp
a63dfb
+/usr/bin/curl $v -kLOJ https://${CDM_CLUSTER_IP}/connector/${CDM_SUNOS_TAR} 
a63dfb
+StopIfError "Could not download https://${CDM_CLUSTER_IP}/connector/${CDM_SUNOS_TAR}"
a63dfb
+
a63dfb
+/usr/bin/tar $v -xzf  $CDM_SUNOS_TAR
a63dfb
+StopIfError "Could not extract $CDM_SUNOS_TAR"
a63dfb
+
a63dfb
+CDM_CERT_FILE=$(find ./ -name "rubrik.crt")
a63dfb
+mv $v ${CDM_KEYS_DIR}/rubrik.crt ${CDM_KEYS_DIR}/rubrik.crt.orig
a63dfb
+cp $v $CDM_CERT_FILE $CDM_KEYS_DIR
a63dfb
+StopIfError "Could not copy replica CDM cluster certificate"
a63dfb
+
a63dfb
+/usr/bin/chmod $v 600 ${CDM_KEYS_DIR}/rubrik.crt
a63dfb
+
a63dfb
+
a63dfb
+LogPrint "Replica Rubrik (CDM) cluster certificate installed."
a63dfb
diff --git a/usr/share/rear/verify/CDM/default/430_gen_rbs_uuid_for_cdm.sh b/usr/share/rear/verify/CDM/default/430_gen_rbs_uuid_for_cdm.sh
a63dfb
new file mode 100644
a63dfb
index 00000000..5e99b79c
a63dfb
--- /dev/null
a63dfb
+++ b/usr/share/rear/verify/CDM/default/430_gen_rbs_uuid_for_cdm.sh
a63dfb
@@ -0,0 +1,29 @@
a63dfb
+# 430_gen_rbs_uuid_for_cdm.sh
a63dfb
+# Reset the UUID used by RBS if the IP address has changed
a63dfb
+
a63dfb
+CDM_RBA_DIR=/etc/rubrik
a63dfb
+CDM_AGENT_UUID=${CDM_RBA_DIR}/conf/uuid
a63dfb
+
a63dfb
+# When USER_INPUT_CDM_SAME_AGENT_UUID has Does this client have the same IP address as the original 'y' was actually meant:
a63dfb
+LogPrint ""
a63dfb
+LogPrint "Found the following IP addresses on this system:"
a63dfb
+LogPrint "$( ip addr | grep inet | cut -d / -f 1 | grep -v 127.0.0.1 | grep -v ::1 )"
a63dfb
+LogPrint ""
a63dfb
+is_true "$USER_INPUT_CDM_SAME_AGENT_UUID" && USER_INPUT_SAME_AGENT_UUID="y"
a63dfb
+while true ; do
a63dfb
+    # Find out if the IP address has changed from the original. If so generate a new UUID.
a63dfb
+    # the default (i.e. the automated response after the timeout) should be 'n':
a63dfb
+    answer="$( UserInput -I CDM_SAME_AGENT_UUID -p "Does this client have the same IP address as the original? (y/n)" -D 'y' -t 300 )"
a63dfb
+    is_true "$answer" && return 0
a63dfb
+    if is_false "$answer" ; then
a63dfb
+        break
a63dfb
+    fi
a63dfb
+    UserOutput "Please answer 'y' or 'n'"
a63dfb
+done
a63dfb
+
a63dfb
+mv $v ${CDM_AGENT_UUID} ${CDM_AGENT_UUID}.old
a63dfb
+/usr/bin/uuidgen | tee -a ${CDM_AGENT_UUID} >&2
a63dfb
+StopIfError "Unable to generate new UUID"
a63dfb
+
a63dfb
+CDM_NEW_AGENT_UUID="true"
a63dfb
+LogPrint "Rubrik (CDM) RBS agent now has new UUID."
a63dfb
diff --git a/usr/share/rear/verify/CDM/default/450_start_cdm_rbs.sh b/usr/share/rear/verify/CDM/default/450_start_cdm_rbs.sh
a63dfb
new file mode 100644
a63dfb
index 00000000..571da1da
a63dfb
--- /dev/null
a63dfb
+++ b/usr/share/rear/verify/CDM/default/450_start_cdm_rbs.sh
a63dfb
@@ -0,0 +1,17 @@
a63dfb
+# 450_start_cdm_rbs.sh
a63dfb
+# Start the Rubrik (CDM) RBS Agent
a63dfb
+
a63dfb
+RBA_DIR=/etc/rubrik
a63dfb
+RBA_BIN_DIR=/usr/bin/rubrik
a63dfb
+
a63dfb
+BOOTSTRAP_DAEMON_OPTS="$( < ${RBA_DIR}/conf/bootstrap_flags.conf )"
a63dfb
+AGENT_DAEMON_OPTS="$( < ${RBA_DIR}/conf/agent_flags.conf )"
a63dfb
+BOOTSTRAP_DAEMON=$RBA_BIN_DIR/bootstrap_agent_main
a63dfb
+AGENT_DAEMON=$RBA_BIN_DIR/backup_agent_main
a63dfb
+
a63dfb
+$BOOTSTRAP_DAEMON $BOOTSTRAP_DAEMON_OPTS
a63dfb
+StopIfError "Unable to start RBS Bootstrap service"
a63dfb
+$AGENT_DAEMON $AGENT_DAEMON_OPTS
a63dfb
+StopIfError "Unable to start RBS Agent service"
a63dfb
+
a63dfb
+LogPrint "Rubrik (CDM) RBS agent started."
a63dfb
-- 
a63dfb
2.25.4
a63dfb