diff --git a/rhel_bmr_rear/rhel_bmr_rear.md b/rhel_bmr_rear/rhel_bmr_rear.md new file mode 100644 index 0000000..e30e9aa --- /dev/null +++ b/rhel_bmr_rear/rhel_bmr_rear.md @@ -0,0 +1,166 @@ +# RHEL Bare Metal Recovery with ReaR and PPDM Generic Application Agent + +## Overview + +This script set enables **Bare Metal Recovery (BMR)** of Red Hat Enterprise Linux (RHEL) systems using [Relax-and-Recover (ReaR)](https://relax-and-recover.org/) integrated with the **Dell PowerProtect Data Manager (PPDM) Generic Application Agent**. + +The backup script dynamically configures ReaR to write its bootable ISO and backup archive directly to the PPDM-managed **BoostFS** target directory, enabling deduplication, policy-based retention, and centralized management via PPDM. + +--- + +## Architecture + +``` +RHEL Host +│ +├── ReaR +│ ├── Bootable ISO (rescue environment) +│ └── backup.tar.gz (full system backup) +│ +└── BoostFS Mount (DD_TARGET_ASSET_BASE_PATH) + └── Managed by PPDM Generic Application Agent + └── Data Protection Domain (DD) +``` + +--- + +## Requirements + +| Component | Details | +|---|---| +| OS | RHEL 8.x / 9.x | +| ReaR | 2.6 or later (`dnf install rear`) | +| FUSE | Required for BoostFS (`dnf install fuse`) | +| PPDM | 19.22 or later | +| Agent Type | **PaaS** (required for Generic Application Agent) | +| Privileges | Root | + +--- + +## PPDM Configuration + +### Application Type +The asset must be configured as **PaaS** type in PPDM. + +### Environment Variables (injected by PPDM) + +| Variable | Description | +|---|---| +| `DD_TARGET_ASSET_BASE_PATH` | BoostFS mount point (managed by PPDM — do not mount/unmount manually) | +| `BACKUP_LEVEL` | Always treated as `FULL` for BMR | +| `ASSET_USERNAME` | Asset credentials (if configured) | +| `ASSET_PASSWORD` | Asset credentials (if configured) | + +> **Important:** PPDM mounts and unmounts BoostFS automatically. Do **not** call `boostfs mount/unmount` commands from within the script. + +--- + +## Files + +| File | Description | +|---|---| +| `rhel_bmr_rear_backup.sh` | Main backup script — configures ReaR and runs `rear mkbackup` | +| `rhel_bmr_rear.md` | This documentation | + +--- + +## Backup Flow + +1. PPDM mounts BoostFS at `DD_TARGET_ASSET_BASE_PATH` +2. Backup script runs as root +3. Existing `/etc/rear/site.conf` is preserved (restored after backup) +4. ReaR is dynamically configured to write output to `DD_TARGET_ASSET_BASE_PATH` +5. `rear mkbackup` creates: + - `.iso` — bootable rescue environment + - `backup.tar.gz` — full system backup archive +6. PPDM unmounts BoostFS and deduplicates data to DD + +--- + +## Restore Flow + +Bare metal recovery requires booting the target machine from the ReaR ISO: + +1. Restore the PPDM backup to a local or network-accessible path +2. Boot the target machine from the ISO (iDRAC virtual media, USB, PXE, etc.) +3. At the ReaR rescue menu, select **Recover \** +4. ReaR will automatically locate `backup.tar.gz` and restore the system +5. Reboot and verify + +--- + +## ReaR Configuration Files (`local.conf`) + +### Configuration Loading Order + +ReaR loads configuration files in the following order: + +``` +/etc/rear/default.conf ← ReaR built-in defaults (do not edit) + ↓ +/etc/rear/site.conf ← Dynamically generated by this script (backed up and restored) + ↓ +/etc/rear/local.conf ← Host-specific overrides (loaded last, overrides site.conf) +``` + +> **Important:** Because `local.conf` is loaded after `site.conf`, any conflicting settings in `local.conf` will override the values set by this script. + +--- + +### Default `local.conf` (no changes required) + +The default `local.conf` shipped with ReaR has all lines commented out and requires no modification: + +```bash +# Default is to create Relax-and-Recover rescue media as ISO image +# OUTPUT=ISO +# BACKUP=NETFS +# BACKUP_URL=nfs://192.168.122.1/tmp +# ... +``` + +--- + +### If `local.conf` Has Been Customized + +If any of the following settings are **uncommented**, they will conflict with this script. Comment out or remove the affected lines before running the backup. + +| Setting | Reason for conflict | +|---|---| +| `BACKUP_URL` | Overrides the BoostFS target path set by this script | +| `OUTPUT_URL` | Overrides the ISO output destination | +| `OUTPUT` | May change the output format away from ISO | +| `BACKUP` | May change the backup method away from NETFS | + +**Verification command:** + +```bash +# Show all active (non-commented) settings in local.conf +grep -v '^\s*#' /etc/rear/local.conf | grep -v '^\s*$' +# Empty output means the default configuration is in place — no action needed +``` + +--- + +## Optional Customization + +To exclude specific paths from the backup, set `EXCLUDE_BACKUP` before calling the script: + +```bash +export EXCLUDE_BACKUP="/mnt/scratch /tmp/large_data" +``` + +--- + +## Known Limitations + +- Incremental BMR is not supported; `BACKUP_LEVEL` is always treated as FULL. +- ReaR ISO size can be large (typically 300–600 MB). Plan DD capacity accordingly. +- For Azure Local / Hyper-V guest RHEL VMs, Arc-enabled VM restoration after BMR is subject to Microsoft Arc integration constraints (not PPDM-specific). + +--- + +## Author + +- takashi.odagiri@dell.com +- Tested with PPDM 19.22 on RHEL 9.3 \ No newline at end of file diff --git a/rhel_bmr_rear/rhel_bmr_rear_backup.sh b/rhel_bmr_rear/rhel_bmr_rear_backup.sh new file mode 100644 index 0000000..66e0d76 --- /dev/null +++ b/rhel_bmr_rear/rhel_bmr_rear_backup.sh @@ -0,0 +1,169 @@ +#!/bin/bash +# ============================================================================== +# PPDM Generic Application Agent - RHEL Bare Metal Recovery (ReaR) Backup Script +# ============================================================================== +# Description : Creates a ReaR bootable ISO and system backup, storing output +# to the PPDM-managed BoostFS target directory. +# Requirements: - ReaR (relax-and-recover) installed on the target host +# - FUSE installed (required for BoostFS) +# - PPDM Generic Application Agent (PaaS type) configured +# - Run as root +# Tested PPDM : 19.22 +# Author : +# ============================================================================== + +set -euo pipefail + +# ------------------------------------------------------------------------------ +# PPDM Environment Variables (injected by PPDM agent) +# ------------------------------------------------------------------------------ +# DD_TARGET_ASSET_BASE_PATH : BoostFS mount point managed by PPDM +# BACKUP_LEVEL : FULL (incremental not supported for BMR) +# ASSET_USERNAME : Asset credentials (if required) +# ASSET_PASSWORD : Asset credentials (if required) +# +# Note: Application Type must be set to "PaaS" in PPDM asset configuration. +# ------------------------------------------------------------------------------ + +REAR_CONFIG_DIR="/etc/rear" +REAR_SITE_CONF="${REAR_CONFIG_DIR}/site.conf" +REAR_SITE_CONF_BACKUP="${REAR_CONFIG_DIR}/site.conf.ppdm_backup" +TIMESTAMP=$(date +"%Y%m%d_%H%M%S") +LOGFILE="/var/log/ppdm_rear_backup_${TIMESTAMP}.log" + +# ============================================================================== +# Functions +# ============================================================================== + +log() { + echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "${LOGFILE}" +} + +error_exit() { + log "ERROR: $*" + restore_rear_config + exit 1 +} + +check_prerequisites() { + log "Checking prerequisites..." + + # Root check + [[ $EUID -eq 0 ]] || error_exit "This script must be run as root." + + # ReaR installed + command -v rear &>/dev/null || error_exit "ReaR is not installed. Install with: dnf install rear" + + # PPDM target path + [[ -n "${DD_TARGET_ASSET_BASE_PATH:-}" ]] || \ + error_exit "DD_TARGET_ASSET_BASE_PATH is not set. Ensure PPDM agent is configured correctly." + + # Target path accessible + [[ -d "${DD_TARGET_ASSET_BASE_PATH}" ]] || \ + error_exit "Target path '${DD_TARGET_ASSET_BASE_PATH}' does not exist or is not mounted." + + # BACKUP_LEVEL check (BMR only supports FULL) + if [[ "${BACKUP_LEVEL:-FULL}" != "FULL" ]]; then + log "WARNING: BACKUP_LEVEL='${BACKUP_LEVEL}' is not supported for BMR. Proceeding as FULL." + fi + + log "Prerequisites OK." +} + +backup_rear_config() { + if [[ -f "${REAR_SITE_CONF}" ]]; then + log "Backing up existing ReaR site.conf..." + cp "${REAR_SITE_CONF}" "${REAR_SITE_CONF_BACKUP}" + fi +} + +restore_rear_config() { + if [[ -f "${REAR_SITE_CONF_BACKUP}" ]]; then + log "Restoring original ReaR site.conf..." + mv "${REAR_SITE_CONF_BACKUP}" "${REAR_SITE_CONF}" + else + # No original existed — remove the one we created + [[ -f "${REAR_SITE_CONF}" ]] && rm -f "${REAR_SITE_CONF}" + fi +} + +configure_rear() { + log "Configuring ReaR to target: ${DD_TARGET_ASSET_BASE_PATH}" + + mkdir -p "${REAR_CONFIG_DIR}" + + cat > "${REAR_SITE_CONF}" <&1 | tee -a "${LOGFILE}" || \ + error_exit "ReaR backup failed. Check ${LOGFILE} for details." + log "ReaR backup completed successfully." +} + +verify_output() { + log "Verifying output files in ${DD_TARGET_ASSET_BASE_PATH}..." + + local hostname + hostname=$(hostname -s) + + # ReaR typically writes: .iso and backup.tar.gz + local iso_file + iso_file=$(find "${DD_TARGET_ASSET_BASE_PATH}" -name "${hostname}*.iso" -newer "${LOGFILE}" 2>/dev/null | head -1) + + local backup_file + backup_file=$(find "${DD_TARGET_ASSET_BASE_PATH}" -name "backup.tar*" -newer "${LOGFILE}" 2>/dev/null | head -1) + + if [[ -z "${iso_file}" ]]; then + log "WARNING: ISO file not found in target path. Verify ReaR output." + else + log "ISO : ${iso_file} ($(du -sh "${iso_file}" | cut -f1))" + fi + + if [[ -z "${backup_file}" ]]; then + log "WARNING: Backup archive not found in target path." + else + log "Backup archive: ${backup_file} ($(du -sh "${backup_file}" | cut -f1))" + fi +} + +# ============================================================================== +# Main +# ============================================================================== + +log "======================================================" +log " PPDM Generic App Agent - RHEL BMR (ReaR) Backup" +log " Host : $(hostname)" +log " PPDM Target: ${DD_TARGET_ASSET_BASE_PATH:-NOT SET}" +log " Backup Level: ${BACKUP_LEVEL:-FULL}" +log "======================================================" + +check_prerequisites +backup_rear_config +configure_rear +run_rear_backup +verify_output +restore_rear_config + +log "Backup script completed. Log: ${LOGFILE}" +exit 0 \ No newline at end of file diff --git a/scripts/rhel_bmr_rear/rhel_bmr_rear.md b/scripts/rhel_bmr_rear/rhel_bmr_rear.md new file mode 100644 index 0000000..e30e9aa --- /dev/null +++ b/scripts/rhel_bmr_rear/rhel_bmr_rear.md @@ -0,0 +1,166 @@ +# RHEL Bare Metal Recovery with ReaR and PPDM Generic Application Agent + +## Overview + +This script set enables **Bare Metal Recovery (BMR)** of Red Hat Enterprise Linux (RHEL) systems using [Relax-and-Recover (ReaR)](https://relax-and-recover.org/) integrated with the **Dell PowerProtect Data Manager (PPDM) Generic Application Agent**. + +The backup script dynamically configures ReaR to write its bootable ISO and backup archive directly to the PPDM-managed **BoostFS** target directory, enabling deduplication, policy-based retention, and centralized management via PPDM. + +--- + +## Architecture + +``` +RHEL Host +│ +├── ReaR +│ ├── Bootable ISO (rescue environment) +│ └── backup.tar.gz (full system backup) +│ +└── BoostFS Mount (DD_TARGET_ASSET_BASE_PATH) + └── Managed by PPDM Generic Application Agent + └── Data Protection Domain (DD) +``` + +--- + +## Requirements + +| Component | Details | +|---|---| +| OS | RHEL 8.x / 9.x | +| ReaR | 2.6 or later (`dnf install rear`) | +| FUSE | Required for BoostFS (`dnf install fuse`) | +| PPDM | 19.22 or later | +| Agent Type | **PaaS** (required for Generic Application Agent) | +| Privileges | Root | + +--- + +## PPDM Configuration + +### Application Type +The asset must be configured as **PaaS** type in PPDM. + +### Environment Variables (injected by PPDM) + +| Variable | Description | +|---|---| +| `DD_TARGET_ASSET_BASE_PATH` | BoostFS mount point (managed by PPDM — do not mount/unmount manually) | +| `BACKUP_LEVEL` | Always treated as `FULL` for BMR | +| `ASSET_USERNAME` | Asset credentials (if configured) | +| `ASSET_PASSWORD` | Asset credentials (if configured) | + +> **Important:** PPDM mounts and unmounts BoostFS automatically. Do **not** call `boostfs mount/unmount` commands from within the script. + +--- + +## Files + +| File | Description | +|---|---| +| `rhel_bmr_rear_backup.sh` | Main backup script — configures ReaR and runs `rear mkbackup` | +| `rhel_bmr_rear.md` | This documentation | + +--- + +## Backup Flow + +1. PPDM mounts BoostFS at `DD_TARGET_ASSET_BASE_PATH` +2. Backup script runs as root +3. Existing `/etc/rear/site.conf` is preserved (restored after backup) +4. ReaR is dynamically configured to write output to `DD_TARGET_ASSET_BASE_PATH` +5. `rear mkbackup` creates: + - `.iso` — bootable rescue environment + - `backup.tar.gz` — full system backup archive +6. PPDM unmounts BoostFS and deduplicates data to DD + +--- + +## Restore Flow + +Bare metal recovery requires booting the target machine from the ReaR ISO: + +1. Restore the PPDM backup to a local or network-accessible path +2. Boot the target machine from the ISO (iDRAC virtual media, USB, PXE, etc.) +3. At the ReaR rescue menu, select **Recover \** +4. ReaR will automatically locate `backup.tar.gz` and restore the system +5. Reboot and verify + +--- + +## ReaR Configuration Files (`local.conf`) + +### Configuration Loading Order + +ReaR loads configuration files in the following order: + +``` +/etc/rear/default.conf ← ReaR built-in defaults (do not edit) + ↓ +/etc/rear/site.conf ← Dynamically generated by this script (backed up and restored) + ↓ +/etc/rear/local.conf ← Host-specific overrides (loaded last, overrides site.conf) +``` + +> **Important:** Because `local.conf` is loaded after `site.conf`, any conflicting settings in `local.conf` will override the values set by this script. + +--- + +### Default `local.conf` (no changes required) + +The default `local.conf` shipped with ReaR has all lines commented out and requires no modification: + +```bash +# Default is to create Relax-and-Recover rescue media as ISO image +# OUTPUT=ISO +# BACKUP=NETFS +# BACKUP_URL=nfs://192.168.122.1/tmp +# ... +``` + +--- + +### If `local.conf` Has Been Customized + +If any of the following settings are **uncommented**, they will conflict with this script. Comment out or remove the affected lines before running the backup. + +| Setting | Reason for conflict | +|---|---| +| `BACKUP_URL` | Overrides the BoostFS target path set by this script | +| `OUTPUT_URL` | Overrides the ISO output destination | +| `OUTPUT` | May change the output format away from ISO | +| `BACKUP` | May change the backup method away from NETFS | + +**Verification command:** + +```bash +# Show all active (non-commented) settings in local.conf +grep -v '^\s*#' /etc/rear/local.conf | grep -v '^\s*$' +# Empty output means the default configuration is in place — no action needed +``` + +--- + +## Optional Customization + +To exclude specific paths from the backup, set `EXCLUDE_BACKUP` before calling the script: + +```bash +export EXCLUDE_BACKUP="/mnt/scratch /tmp/large_data" +``` + +--- + +## Known Limitations + +- Incremental BMR is not supported; `BACKUP_LEVEL` is always treated as FULL. +- ReaR ISO size can be large (typically 300–600 MB). Plan DD capacity accordingly. +- For Azure Local / Hyper-V guest RHEL VMs, Arc-enabled VM restoration after BMR is subject to Microsoft Arc integration constraints (not PPDM-specific). + +--- + +## Author + +- takashi.odagiri@dell.com +- Tested with PPDM 19.22 on RHEL 9.3 \ No newline at end of file diff --git a/scripts/rhel_bmr_rear/rhel_bmr_rear_backup.sh b/scripts/rhel_bmr_rear/rhel_bmr_rear_backup.sh new file mode 100644 index 0000000..66e0d76 --- /dev/null +++ b/scripts/rhel_bmr_rear/rhel_bmr_rear_backup.sh @@ -0,0 +1,169 @@ +#!/bin/bash +# ============================================================================== +# PPDM Generic Application Agent - RHEL Bare Metal Recovery (ReaR) Backup Script +# ============================================================================== +# Description : Creates a ReaR bootable ISO and system backup, storing output +# to the PPDM-managed BoostFS target directory. +# Requirements: - ReaR (relax-and-recover) installed on the target host +# - FUSE installed (required for BoostFS) +# - PPDM Generic Application Agent (PaaS type) configured +# - Run as root +# Tested PPDM : 19.22 +# Author : +# ============================================================================== + +set -euo pipefail + +# ------------------------------------------------------------------------------ +# PPDM Environment Variables (injected by PPDM agent) +# ------------------------------------------------------------------------------ +# DD_TARGET_ASSET_BASE_PATH : BoostFS mount point managed by PPDM +# BACKUP_LEVEL : FULL (incremental not supported for BMR) +# ASSET_USERNAME : Asset credentials (if required) +# ASSET_PASSWORD : Asset credentials (if required) +# +# Note: Application Type must be set to "PaaS" in PPDM asset configuration. +# ------------------------------------------------------------------------------ + +REAR_CONFIG_DIR="/etc/rear" +REAR_SITE_CONF="${REAR_CONFIG_DIR}/site.conf" +REAR_SITE_CONF_BACKUP="${REAR_CONFIG_DIR}/site.conf.ppdm_backup" +TIMESTAMP=$(date +"%Y%m%d_%H%M%S") +LOGFILE="/var/log/ppdm_rear_backup_${TIMESTAMP}.log" + +# ============================================================================== +# Functions +# ============================================================================== + +log() { + echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "${LOGFILE}" +} + +error_exit() { + log "ERROR: $*" + restore_rear_config + exit 1 +} + +check_prerequisites() { + log "Checking prerequisites..." + + # Root check + [[ $EUID -eq 0 ]] || error_exit "This script must be run as root." + + # ReaR installed + command -v rear &>/dev/null || error_exit "ReaR is not installed. Install with: dnf install rear" + + # PPDM target path + [[ -n "${DD_TARGET_ASSET_BASE_PATH:-}" ]] || \ + error_exit "DD_TARGET_ASSET_BASE_PATH is not set. Ensure PPDM agent is configured correctly." + + # Target path accessible + [[ -d "${DD_TARGET_ASSET_BASE_PATH}" ]] || \ + error_exit "Target path '${DD_TARGET_ASSET_BASE_PATH}' does not exist or is not mounted." + + # BACKUP_LEVEL check (BMR only supports FULL) + if [[ "${BACKUP_LEVEL:-FULL}" != "FULL" ]]; then + log "WARNING: BACKUP_LEVEL='${BACKUP_LEVEL}' is not supported for BMR. Proceeding as FULL." + fi + + log "Prerequisites OK." +} + +backup_rear_config() { + if [[ -f "${REAR_SITE_CONF}" ]]; then + log "Backing up existing ReaR site.conf..." + cp "${REAR_SITE_CONF}" "${REAR_SITE_CONF_BACKUP}" + fi +} + +restore_rear_config() { + if [[ -f "${REAR_SITE_CONF_BACKUP}" ]]; then + log "Restoring original ReaR site.conf..." + mv "${REAR_SITE_CONF_BACKUP}" "${REAR_SITE_CONF}" + else + # No original existed — remove the one we created + [[ -f "${REAR_SITE_CONF}" ]] && rm -f "${REAR_SITE_CONF}" + fi +} + +configure_rear() { + log "Configuring ReaR to target: ${DD_TARGET_ASSET_BASE_PATH}" + + mkdir -p "${REAR_CONFIG_DIR}" + + cat > "${REAR_SITE_CONF}" <&1 | tee -a "${LOGFILE}" || \ + error_exit "ReaR backup failed. Check ${LOGFILE} for details." + log "ReaR backup completed successfully." +} + +verify_output() { + log "Verifying output files in ${DD_TARGET_ASSET_BASE_PATH}..." + + local hostname + hostname=$(hostname -s) + + # ReaR typically writes: .iso and backup.tar.gz + local iso_file + iso_file=$(find "${DD_TARGET_ASSET_BASE_PATH}" -name "${hostname}*.iso" -newer "${LOGFILE}" 2>/dev/null | head -1) + + local backup_file + backup_file=$(find "${DD_TARGET_ASSET_BASE_PATH}" -name "backup.tar*" -newer "${LOGFILE}" 2>/dev/null | head -1) + + if [[ -z "${iso_file}" ]]; then + log "WARNING: ISO file not found in target path. Verify ReaR output." + else + log "ISO : ${iso_file} ($(du -sh "${iso_file}" | cut -f1))" + fi + + if [[ -z "${backup_file}" ]]; then + log "WARNING: Backup archive not found in target path." + else + log "Backup archive: ${backup_file} ($(du -sh "${backup_file}" | cut -f1))" + fi +} + +# ============================================================================== +# Main +# ============================================================================== + +log "======================================================" +log " PPDM Generic App Agent - RHEL BMR (ReaR) Backup" +log " Host : $(hostname)" +log " PPDM Target: ${DD_TARGET_ASSET_BASE_PATH:-NOT SET}" +log " Backup Level: ${BACKUP_LEVEL:-FULL}" +log "======================================================" + +check_prerequisites +backup_rear_config +configure_rear +run_rear_backup +verify_output +restore_rear_config + +log "Backup script completed. Log: ${LOGFILE}" +exit 0 \ No newline at end of file