Manual HA OS Backup Restore Procedure
Technical Reference — Learned from OBH Migration 2026-05-08
หัวข้อที่มีชื่อว่า “Technical Reference — Learned from OBH Migration 2026-05-08”Context: When restoring a HA backup via the built-in UI/API fails (e.g., stuck at
“Restarting Home Assistant” stage), this manual procedure extracts and restores data
directly from the encrypted .tar backup file.
Why the Built-in Restore Fails
หัวข้อที่มีชื่อว่า “Why the Built-in Restore Fails”The HA Supervisor restore API performs these stages in order:
addon_repositories— add addon reposfolders— restore ssl, share, etc.home_assistant— stop Core, pull target version image, extract config, restart Coreaddons— pull and restore each add-onfinishing_file— finalize
Common failure point: Stage 3 (home_assistant) gets stuck when:
- The backup’s HA Core version differs from the installed version (triggers image pull)
- The image pull is slow/fails — Supervisor hangs indefinitely with no timeout
- The system enters
freezestate and blocks all further operations
Key lesson: If Core versions don’t match, the restore will attempt to pull the old image and may never complete. Splitting the restore into separate manual steps avoids this.
Prerequisites
หัวข้อที่มีชื่อว่า “Prerequisites”- SSH access to HA OS (via SSH add-on or VM console)
- VM console access (for
loginshell — needed for root filesystem writes) - The
.tarbackup file uploaded to/backup/on the new HA instance - The backup encryption password
Step-by-Step Manual Restore
หัวข้อที่มีชื่อว่า “Step-by-Step Manual Restore”Step 1: Extract the Backup Tar
หัวข้อที่มีชื่อว่า “Step 1: Extract the Backup Tar”From VM console (login to get root shell):
loginmkdir -p /tmp/restorecd /tmp/restoretar xf /backup/<backup_filename>.tarlsThis produces:
backup.json— metadata (slug, date, version, addon list)homeassistant.tar.gz— encrypted HA Core configssl.tar.gz— encrypted SSL certificates<addon_slug>.tar.gz— encrypted add-on data (one per add-on)
Step 2: Install SecureTar Decryption Library
หัวข้อที่มีชื่อว่า “Step 2: Install SecureTar Decryption Library”HA backup .tar.gz files use SecureTar format (not standard gzip). Install the library:
pip3 install --break-system-packages securetarStep 3: Decrypt and Extract HA Core Config
หัวข้อที่มีชื่อว่า “Step 3: Decrypt and Extract HA Core Config”From VM console (root shell required for write access):
cd /tmp/restoremkdir -p /tmp/restore/ha_config
python3 << 'PYEOF'from securetar import SecureTarFilefrom pathlib import Path
with SecureTarFile( Path("homeassistant.tar.gz"), password="YOUR_BACKUP_PASSWORD", gzip=True) as tar: tar.extractall(path="/tmp/restore/ha_config", filter="fully_trusted")print("SUCCESS")PYEOFThis extracts to /tmp/restore/ha_config/data/config/ which contains:
configuration.yaml,automations.yaml,scripts.yaml,secrets.yaml.storage/— dashboards, entity/device registry, auth, integrationscustom_components/— HACS integrationsthemes/,www/, etc.
Step 4: Copy Config to HA Config Directory
หัวข้อที่มีชื่อว่า “Step 4: Copy Config to HA Config Directory”# Copy main config filescp -a /tmp/restore/ha_config/data/config/* /root/homeassistant/
# Copy .storage (hidden directory, needs explicit copy)cp -a /tmp/restore/ha_config/data/config/.storage/* /root/homeassistant/.storage/
# Restart HA Coreha core restartNote: If source and destination are the same mount point (you’ll see “same file” errors), the config is already in place — just restart Core.
Step 5: Restore .storage from Live Old HA (if backup .storage is incomplete)
หัวข้อที่มีชื่อว่า “Step 5: Restore .storage from Live Old HA (if backup .storage is incomplete)”If dashboards or registries are missing, copy .storage directly from the old running HA instance:
# From a jump host that can reach both old and new HA:
# 1. Create tar on old HAssh <old-ha> 'cd /usr/share/hassio/homeassistant && tar czf /tmp/storage_all.tar.gz .storage/'
# 2. Copy to jump hostssh <old-ha> 'cat /tmp/storage_all.tar.gz' > /tmp/storage_all.tar.gz
# 3. Copy to new HA (via SSH add-on)cat /tmp/storage_all.tar.gz | ssh <new-ha> 'cat > /tmp/storage_all.tar.gz'
# 4. On new HA VM console (root shell):logincd /root/homeassistantrm -rf .storagetar xzf /tmp/storage_all.tar.gzha core restartPaths reference:
- Old HA (Debian Supervised):
/usr/share/hassio/homeassistant/.storage/ - New HA OS (VM console):
/root/homeassistant/.storage/ - HA SSH add-on sees config at:
/homeassistant/.storage/(read-only for non-root) - HA Docker container sees config at:
/config/.storage/
Step 6: Restore Add-ons Separately
หัวข้อที่มีชื่อว่า “Step 6: Restore Add-ons Separately”Restore add-ons via API (skipping any you don’t want, e.g., Cloudflare Tunnel):
curl -s -X POST \ -H "Authorization: Bearer $SUPERVISOR_TOKEN" \ -H "Content-Type: application/json" \ http://supervisor/backups/<slug>/restore/partial \ -d '{ "homeassistant": false, "password": "YOUR_BACKUP_PASSWORD", "folders": [], "addons": [ "addon_slug_1", "addon_slug_2" ] }'Important: Do NOT include "homeassistant": true — this triggers the image pull that
causes the freeze. Restore add-ons only.
Monitor progress:
curl -s -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/jobs/infoStep 7: If Supervisor Gets Stuck in Freeze State
หัวข้อที่มีชื่อว่า “Step 7: If Supervisor Gets Stuck in Freeze State”# From VM console:logindocker restart hassio_supervisor
# Wait 30 seconds, then verify:ha supervisor info | grep state# Should show: state: runningCommon Issues and Solutions
หัวข้อที่มีชื่อว่า “Common Issues and Solutions”| Issue | Cause | Solution |
|---|---|---|
Restore stuck at home_assistant stage |
Core version mismatch triggers slow/failed image pull | Skip home_assistant in restore, copy config manually |
Supervisor in freeze state |
Incomplete restore left system frozen | docker restart hassio_supervisor from VM console |
ha CLI returns “unauthorized” from SSH add-on |
Restore changed auth tokens | Use $SUPERVISOR_TOKEN from SSH add-on, or use VM console where ha CLI works without auth |
SSH add-on can’t write to .storage/ |
Add-on runs as non-root, .storage/ is root-owned |
Use VM console (login) for file operations |
SecureTarFile — “unexpected keyword argument ‘key’” |
Wrong API — use password= parameter, not key= |
SecureTarFile(Path("file"), password="...", gzip=True) |
extractall not found on SecureTarFile |
Must use context manager (with ... as tar:) |
The with block returns a standard tarfile.TarFile object |
| Dashboard missing after restore | .storage/lovelace* files not in backup |
Copy from old HA directly (Step 5) |
| “same file” error on cp | Extraction path and config dir are same mount | Config already in place — just ha core restart |
HA OS Filesystem Paths
หัวข้อที่มีชื่อว่า “HA OS Filesystem Paths”| Context | Config Path | .storage Path |
|---|---|---|
VM console (after login) |
/root/homeassistant/ |
/root/homeassistant/.storage/ |
| SSH add-on container | /homeassistant/ |
/homeassistant/.storage/ |
| HA Core container | /config/ |
/config/.storage/ |
| Debian Supervised (host) | /usr/share/hassio/homeassistant/ |
/usr/share/hassio/homeassistant/.storage/ |
| Backups directory (HA OS) | /backup/ |
— |
Backup Encryption Details
หัวข้อที่มีชื่อว่า “Backup Encryption Details”- Format: SecureTar (custom, not OpenSSL)
- File header magic:
SecureTar(hex:5365637572655461720300...) - Encryption: AES-GCM
- Key derivation: PBKDF2-SHA256, salt=
"homeassistant", iterations=10000 - Python library:
securetar(pip install) - Standard
opensslCLI will NOT work for decryption
Documented: 2026-05-08 during OBH HA OS migration from Debian Supervised to HA OS 17.3 Core version at restore: 2026.5.0 | Backup source: 2026.5.0 (upgraded before backup)