ข้ามไปยังเนื้อหา

Manual HA OS Backup Restore Procedure

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.


The HA Supervisor restore API performs these stages in order:

  1. addon_repositories — add addon repos
  2. folders — restore ssl, share, etc.
  3. home_assistant — stop Core, pull target version image, extract config, restart Core
  4. addons — pull and restore each add-on
  5. finishing_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 freeze state 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.


  • SSH access to HA OS (via SSH add-on or VM console)
  • VM console access (for login shell — needed for root filesystem writes)
  • The .tar backup file uploaded to /backup/ on the new HA instance
  • The backup encryption password

From VM console (login to get root shell):

Terminal window
login
mkdir -p /tmp/restore
cd /tmp/restore
tar xf /backup/<backup_filename>.tar
ls

This produces:

  • backup.json — metadata (slug, date, version, addon list)
  • homeassistant.tar.gz — encrypted HA Core config
  • ssl.tar.gz — encrypted SSL certificates
  • <addon_slug>.tar.gz — encrypted add-on data (one per add-on)

HA backup .tar.gz files use SecureTar format (not standard gzip). Install the library:

Terminal window
pip3 install --break-system-packages securetar

From VM console (root shell required for write access):

Terminal window
cd /tmp/restore
mkdir -p /tmp/restore/ha_config
python3 << 'PYEOF'
from securetar import SecureTarFile
from 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")
PYEOF

This extracts to /tmp/restore/ha_config/data/config/ which contains:

  • configuration.yaml, automations.yaml, scripts.yaml, secrets.yaml
  • .storage/ — dashboards, entity/device registry, auth, integrations
  • custom_components/ — HACS integrations
  • themes/, www/, etc.
Terminal window
# Copy main config files
cp -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 Core
ha core restart

Note: If source and destination are the same mount point (you’ll see “same file” errors), the config is already in place — just restart Core.

If dashboards or registries are missing, copy .storage directly from the old running HA instance:

Terminal window
# From a jump host that can reach both old and new HA:
# 1. Create tar on old HA
ssh <old-ha> 'cd /usr/share/hassio/homeassistant && tar czf /tmp/storage_all.tar.gz .storage/'
# 2. Copy to jump host
ssh <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):
login
cd /root/homeassistant
rm -rf .storage
tar xzf /tmp/storage_all.tar.gz
ha core restart

Paths 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/

Restore add-ons via API (skipping any you don’t want, e.g., Cloudflare Tunnel):

Terminal window
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:

Terminal window
curl -s -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/jobs/info
Terminal window
# From VM console:
login
docker restart hassio_supervisor
# Wait 30 seconds, then verify:
ha supervisor info | grep state
# Should show: state: running

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
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/ —
  • 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 openssl CLI 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)