TABLE OF CONTENTS
- Overview
- What You'll Need
- Important Notes
- Prepare and Attach Backup
- Identify Disks
- Mount Backup
- Define Variables
- Dry‑run
- Perform the Copy
- Verify and Clean Up
Overview
Recover public_html
for a cPanel account from a scheduled VPS backup image without overwriting existing files. Applies to CentOS 6 through AlmaLinux/Rocky 9 WHM/cPanel VPS on Mammoth Cloud or BinaryLane. Backup images are raw, byte‑for‑byte. Typical devices: live disk /dev/vda
, attached backup /dev/vdb
(often with a single partition /dev/vdb1
).
What You'll Need
- Root SSH access (or use the mPanel rescue console if SSH is unavailable)
<CPANEL_USER>
: the cPanel account name (e.g.acme
)- Target path:
/home/<CPANEL_USER>/public_html/
Important Notes
Note: This procedure copies files without overwriting existing ones using--ignore-existing
.
rsync -a
preserves ownership, permissions, timestamps, and symlinks.
Run all commands as root.
Prepare and Attach Backup
- In mPanel, create a fresh temporary backup to ensure the server can be restored from its current state if needed (do not overwrite existing backups): https://home.binarylane.com.au/server/-/backups/create
- Select the backup you need to recover files from (not the temporary backup created in step 1), and click Attach. Wait for the attach to complete.
- Login to the server as root using SSH.
Identify Disks
Locate the attached backup device (typically /dev/vdb
):
ls -la /dev/v*
You should see a device named /dev/vdb
. This is the backup image to mount.
Mount Backup
Mount the attached backup read‑only:
mount -o ro /dev/vdb /mnt
Define Variables
Replace placeholders with the actual cPanel user for the content you need to recover, such as CPANEL_USER="mysmallbiz"
:
CPANEL_USER="<CPANEL_USER>" SRC="/mnt/home/$CPANEL_USER/public_html/" DST="/home/$CPANEL_USER/public_html/" DATE="$(date +%F)"
Dry‑run
Perform a no‑impact preview and review the log and counts:
logfile="/root/rsync_${CPANEL_USER}_public_html_dryrun_${DATE}.log" rsync -aiv --ignore-existing --dry-run "$SRC" "$DST" | tee "$logfile" rsync -aiv --ignore-existing --dry-run "$SRC" "$DST" \ | awk '/^>f/ {count++} END {print "\nTotal files to copy: " count}' \ | tee -a "$logfile"
This checks the entire public_html
directory from the backup for files that need to be copied to the working disk without replacing existing files.
Perform the Copy
Once satisfied with the dry‑run, perform the real copy with logging and counts:
logfile="/root/rsync_${CPANEL_USER}_public_html_realrun_${DATE}.log" rsync -aiv --ignore-existing "$SRC" "$DST" | tee "$logfile" rsync -aiv --ignore-existing "$SRC" "$DST" \ | awk '/^>f/ {count++} END {print "\nTotal files copied: " count}' \ | tee -a "$logfile"
Verify and Clean Up
- Confirm recovered files are present under
/home/<CPANEL_USER>/public_html/
and load correctly via your application/website. - Optional: remove the dry‑run and real‑run log files:
rm -f "/root/rsync_${CPANEL_USER}_public_html_dryrun_${DATE}.log" "/root/rsync_${CPANEL_USER}_public_html_realrun_${DATE}.log"
- Unmount the backup before detaching it in mPanel:
umount /mnt
The backup you recovered files from is now detached. The temporary backup created earlier will expire automatically in 7 days.