Back up conversations and keys with Home Assistant
Home Assistant backups can protect nearly everything Pi Agent stores: conversations, API keys, Skills, rclone tokens, and project output. Four rebuildable directories are deliberately excluded. This chapter explains exactly what is covered, what to do after a restore, and why every exported archive containing plaintext credentials must be encrypted and stored carefully.
Why you should make regular backups
Your Home Assistant host may run lighting automations, door locks, energy monitoring, and now Pi Agent. That means a host failure can cost you much more than it once did: you could lose every AI conversation, each provider key you configured, every installed Skill, and the rclone authorization used to upload files to Google Drive. Together, that can represent weeks of work.
- Storage failure: an SD card or drive can become unreadable without warning.
- Failed upgrade: a Home Assistant release or Pi Agent add-on update can prevent the service from starting. Without a recent backup, rollback is difficult (see Chapter 21).
- Accidental deletion: a mistyped command in File editor or SSH can remove important configuration.
- Host migration: backups are the supported way to move from a Pi 4 to a Pi 5, from a Pi to a NUC, or to another location.
Home Assistant Backup packages the selected system configuration, databases, shared data, and each selected add-on's /data/ directory into a .tar archive. You can download it, copy it off-device, upload it to cloud storage, or restore it on another Home Assistant installation.
Pi Agent runs as a Home Assistant add-on so that its persistent data can travel with the same backup. You do not need a separate backup system or another scheduled job. You do, however, need to include the Pi Agent add-on and verify that the backup can be restored.
Pi Agent's /data/pi-agent/ directory map
You do not need to inspect this directory over SSH, but understanding its layout makes the backup boundary clear. The final column shows whether Home Assistant includes each item in a Pi Agent backup:
| Path | Contents | Included in an HA backup? |
|---|---|---|
sessions/*.jsonl | Every conversation with the AI, with one file per Session (see Chapter 8) | Yes |
models.json | Provider configuration and API keys (see Chapter 6) | Yes |
skills/ | Skills you installed or wrote (see Chapter 14) | Yes |
auth.json | OAuth sign-in tokens used for keyless authorization; file mode 600 | Yes |
settings.json | pi-web preferences, including the theme and default provider | Yes |
home/pi-cwd-YYYYMMDD/ | Working directories created by the pi coding agent, including scripts and Skill drafts; names use pi-cwd- plus an 8-digit date | Yes |
projects/<video-name>/final.mp4 | Finished MP4 files, script.md, and voice/ output from the video pipeline (see Chapter 17) | Yes |
rclone/rclone.conf | Google Drive authorization token (see Chapter 19) | Yes |
.video-tools-installed | Empty sentinel file created after the first video-tools installation (see Chapter 18) | Yes (but a missing venv still triggers reinstallation after a restore) |
venv/ | Python environment and packages used by video-tools | No (downloaded again automatically after a restore) |
playwright-cache/ | Chromium browser used by Playwright | No (downloaded again automatically after a restore) |
projects/<video-name>/clips/*.webm | Individual scenes recorded by Playwright as source material | No (can be regenerated) |
projects/<video-name>/segments/*.mp4 | Intermediate video segments produced by ffmpeg | No (can be regenerated) |
A useful rule is: back up your results, not the rebuildable toolchain. Conversations, keys, Skills, rclone authorization, and finished MP4 files are your results. The virtual environment, Chromium download, and intermediate video files can be downloaded or generated again.
auth.json stores it, and losing it means repeating the sign-in flow. Home Assistant includes the file when the Pi Agent add-on is selected for backup.
Why four directories are deliberately excluded
The backup excludes venv/, playwright-cache/, clips/, and segments/ for three reasons:
-
They make every backup much larger
venv/andplaywright-cache/together use about 720 MB. These are the dependencies downloaded during the initial installation described in Chapter 2 and Chapter 18. Including them would add nearly 1 GB to every backup; retaining ten backups could consume roughly 10 GB of space for data that can be downloaded again. -
Video clips and segments can be regenerated
projects/<a-video>/clips/contains scenes captured by Playwright, whilesegments/contains intermediate files produced by ffmpeg. As long as the script, narration, and finished files underprojects/<a-video>/, includingfinal.mp4, are preserved, the workflow can generate those intermediate files again. -
video-tools-initrebuilds the tools automaticallyAt startup,
pi-web-start.shlaunchesvideo-tools-init.shin the background (see Chapter 18). Its check requires both the sentinel file andvenv/bin/python3. Because a backup excludesvenv/andplaywright-cache/, the missing executable triggers a fresh download even if the sentinel file was restored. Allow 3-8 minutes after the first start.
The policy is simple: back up data that cannot be reconstructed elsewhere. Sessions, keys, Skills, rclone tokens, and finished videos belong in the archive; dependencies and intermediate media can be downloaded or generated again.
Make a full backup
The first backup takes only a few steps. Once you know the process, make it a regular monthly routine—or automate it more frequently.
-
Open the Home Assistant backup page
In the Home Assistant sidebar, select Settings → System → Backups. The page may be empty the first time you open it, or it may show a backup created by an existing schedule. On releases from before 2023, the feature appeared under Settings → System → Server Controls; that route no longer exists in current releases.
-
Select “Backup now,” then “Manual backup”
In the Home Assistant 2024 and later interface, select Backup now → Manual backup. Older tutorials may refer to “Create backup” or “Full backup.” On the data-selection screen, keep everything selected for your first backup: Home Assistant configuration, each installed add-on, shared folders, and media. This includes the Pi Agent add-on and its
/data/pi-agent/directory. To reduce archive size, you may omit large media and share directories, but leave Pi Agent selected. -
Give the backup a descriptive name
Replace the generic version-and-timestamp name with something you will recognize later, such as
2026-08-14-full,before-pi-agent-upgrade, orprovider-keys-configured. A clear name makes the right restore point easier to identify. -
Protect the encryption key and Backup Emergency Kit
Home Assistant 2025 releases automatically generate a backup encryption key and prompt you to download the Backup Emergency Kit, a .txt file containing that key. Store the kit in a password manager or print it and keep it securely. If both the original Home Assistant system and this key are lost, the encrypted backup cannot be restored; there is no official backdoor. Keep the kit separate from both the host and the backup archive—not beside the archive in the same cloud folder.
-
Choose storage destinations and wait for completion
Choose one or more destinations: local storage, Nabu Casa, mounted network storage, or a destination supplied by a third-party add-on such as Google Drive Backup or Samba Backup. A home backup usually takes 1-10 minutes, depending on data volume and installed add-ons. When it appears in the list, use its menu to download the .tar archive and keep an off-device copy.
Important: a backup is not proven until you test a restore
Creating an archive is only the first step. The real test is whether that archive can restore a working system. An untested backup may fail when you need it most.
-
Prepare a Home Assistant system that is not your production host
Use another Pi, an idle NUC, a Home Assistant OS virtual machine in VirtualBox, or a small VPS running Home Assistant Supervised. Do not run the test restore on your production host. A restore overwrites current data, so a failed test there could leave you without either copy.
-
Install Home Assistant, upload the backup, and restore it
On the test system, open Settings → System → Backups, use the menu in the upper-right corner to upload the downloaded
.tarfile, open its backup card, and select Restore backup. For an encrypted backup, enter the key from the Backup Emergency Kit or the password you set. Without that secret, the restore cannot proceed. Allow Home Assistant to restart when prompted. -
Wait for Pi Agent and video-tools
Pi Agent should return to the sidebar after the restore. During the first 3-8 minutes,
video-tools-initdownloads the 720 MB Python environment and Chromium bundle described in Chapter 18. You can open pi-web during this period, but the video pipeline is not ready yet. -
Open pi-web and verify every item
Confirm the restored data and service directly:
- Session list: all previous conversations are present
- Models panel: every provider is present, and Test succeeds
- Skills panel: every installed Skill appears in the list
- New conversation: the selected provider answers a simple question
Not recommended: manually rsync /data/pi-agent/ to another host
Although copying /data/pi-agent/ with rsync over SSH may appear equivalent to a backup, it introduces three practical risks:
- Data and add-on versions may not match. The formats of
models.jsonandsessions/*.jsonlmay change between Pi Agent releases. Copying older data into a newer add-on—or newer data into an older one—can prevent pi-web from reading it. A Home Assistant backup records add-on information with the data, making version alignment easier to preserve. - You can omit add-on state. Add-ons also store data under
/data/as well as settings such as options.json, configuration values, environment variables, and log_level. Home Assistant backs up the selected add-on as a unit; a hand-built copy can easily miss part of it. - You can create an inconsistent video-tools installation. A manual copy may carry
/data/pi-agent/.video-tools-installedwithout a complete virtual environment. Whenvideo-tools-init.shruns, its normal startup check also looks forvenv/bin/python3, but a partial or mismatched toolchain can still fail when the video pipeline runs. If necessary, enablereset_video_toolsin Configuration and restart the add-on (see Chapter 18).
Use Home Assistant Backup for complete Pi Agent recovery. It is the supported mechanism and is less likely to produce an incomplete or version-mismatched restore.
/data/pi-agent/ is reasonable only when sharing a Skill. You can package skills/<a-skill>/ as a ZIP file and have another user extract it under /data/pi-agent/skills/. A Skill is Markdown content rather than version-bound application state.
Store API keys separately
Pi Agent stores provider keys as plaintext in /data/pi-agent/models.json. When Pi Agent is selected, Home Assistant places that file inside the backup archive. Keep a second copy of every API key in a password manager such as 1Password, Bitwarden, or iCloud Keychain for two reasons:
- Independent recovery: if a backup is missing, corrupt, or too old, the password-manager copy can restore provider access.
- An unencrypted backup exposes the key. A
.tararchive can contain plaintextdata/pi-agent/models.jsonand rclone.conf. If an archive leaks, revoke and replace every exposed provider key and storage token. Your password manager tells you exactly which credentials to rotate.
When you create a key (as in Chapter 5), save it immediately with a clear label such as Pi Agent provider key / creation date / official provider site. Update the password-manager entry whenever you replace the key in the Models panel. Encrypt every archive stored off-device, and never share a backup archive as a troubleshooting attachment.
SKILL.md. Skill content may be sent to the selected provider (see Chapter 14). Keep keys only in models.json through the Models UI and in your password manager.
Create a backup before upgrading Pi Agent
Before every Pi Agent add-on update, make a fresh backup. Treat this as a requirement for major releases with breaking changes, such as v0.13.0, rather than as optional housekeeping.
The Pi Agent add-on page has no Downgrade button. Home Assistant's add-on store normally offers only the current release. If an update changes behavior or prevents startup, a pre-upgrade backup provides the practical route back to the earlier state.
Known high-risk transitions are summarized below. See the current notes in Chapter 21 before upgrading:
| Version transition | Change | Risk without a backup |
|---|---|---|
| ~ v0.13.0 | API keys moved from add-on configuration to the pi-web Models panel | This is a hard cut with no automatic migration. Record every key before upgrading, then enter each one again in Models. |
| ~ v0.10.0 | The pi coding agent working directory moved from the container root to /data/pi-agent/home/ | Older pi-cwd-* directories could be removed during the upgrade and lost without a backup. |
| Video pipeline restructuring | The video-tools venv layout may change | The video pipeline may be temporarily unavailable. Automatic rebuilding usually resolves it, but a backup protects your unique project data. |
Recommended procedure: Settings → System → Backups → Backup now → Manual backup → select a full backup → name it “Before upgrade <date>” → wait for completion → return to the add-on page and select Update. About 5 minutes of preparation gives you a recovery point.
Move to a new Home Assistant host
Use the same backup mechanism when moving from a Pi to a NUC, upgrading from an older Pi to a Pi 5, or relocating the system. The process resembles a restore test, but this time the new host becomes production:
-
Create a final, clean backup on the old host
Take extra care with this last backup. After it completes, do not start new conversations or change settings on the old host, because those changes will not be in the archive. Encrypt the backup, store an off-device copy on a USB drive, upload it to Nabu Casa, or use all three for the strongest protection.
-
Install Home Assistant on the new host, but no add-ons
Install Home Assistant OS or Home Assistant Supervised on the new hardware and connect it to the network. Do not install Pi Agent manually. The restore installs the backed-up add-on and its data together.
-
Restore the old backup on the new host
Open Settings → System → Backups, upload the backup, and select Restore. Enter the encryption key or password when prompted. Home Assistant restarts, and Pi Agent should then appear in the sidebar.
-
Allow 3-8 minutes for video-tools to download again
The new host has no restored
venv/orplaywright-cache/. During startup, s6-overlay triggers the background download. pi-web, chats, and Session history are available while it runs, but the video pipeline is not. Wait until the log showsvideo-tools-init done. -
Test a conversation and confirm provider access
Open a new Session, choose a configured provider, and ask a simple question. A response confirms the key and network path are working. A 401 or 403 response may mean the provider rejected the changed network IP, requires an IP allowlist update, or has revoked the credential. Those are provider-account issues rather than Pi Agent restore failures.
models.json travels with the backup, as Chapter 5 explains. The same principle applies to Skills, the rclone token, and conversation history. Even so, retaining keys separately in a password manager protects you if the archive cannot be restored.
Common pitfalls
-
Is a backup larger than 1 GB normal?
Yes. A full backup includes the selected
/data/directories for all add-ons, which may include InfluxDB, Node-RED, an MQTT broker, and File editor in addition to Pi Agent. If you need only Pi Agent, create a partial backup and select Home Assistant Core and the Pi Agent add-on. Depending on Session history and project output, that archive may be only tens or hundreds of megabytes. A partial backup restores only the components you selected; it does not protect other add-ons. -
Pi Agent is empty after the restore
The Pi Agent add-on was probably omitted when the backup was created. Open the completed backup card and inspect its included content. If Woow HA Pi Agent is absent from the Add-ons section, create another backup. Under Backup now → Manual backup, select Woow HA Pi Agent. Current Home Assistant versions package an add-on and its data as one selection, including
/data/pi-agent/. If your interface has separate add-on and add-on-data checkboxes, it is very old; create a full backup before upgrading, as described in Chapter 21. -
The key was restored, but the Models test fails
First determine whether the credential remains valid. If it does, the API service may have changed its endpoint or path; update the provider's base URL in the Models panel using the current values in Chapter 11, then run Test again. If the credential has expired or been revoked—or you replaced it in the provider console—create a new key and save it in both Pi Agent and your password manager. A backup cannot reactivate a revoked credential.
-
The video pipeline does not respond
For 3-8 minutes after a restore,
video-tools-initmay still be running. Check the Home Assistant add-on log forvideo-tools-init done. If it has not completed after more than ten minutes or the log shows an error, enablereset_video_toolson the add-on Configuration page, restart the add-on, and wait for another download (see Chapter 18). -
The Skills panel is empty, but files exist under
/data/pi-agent/skills/This rare condition means the files were restored but pi-web has not rescanned them. Start a new conversation rather than merely refreshing the page; opening a new Session forces a scan of the Skills directory. If the Skills still do not appear, restart the Pi Agent add-on from its Home Assistant add-on page.
-
rclone no longer uploads to Google Drive after the restore
The OAuth token in
rclone.confcan expire or be revoked, particularly when restoring an old backup. As described in Chapter 19, open a shell in the add-on container and runrclone config reconnect gdrive:, replacinggdrive:with your remote name and retaining the colon. This repeats the OAuth authorization flow without rebuilding the entirerclone config. Errors such asoauth2: token expiredare also covered in Chapter 19. -
The Backup Emergency Kit is missing, and restore requests a password
Home Assistant 2025 scheduled backups use an automatically generated encryption key recorded in the Backup Emergency Kit. If the original Home Assistant system still works, open Settings → System → Backups → upper-right menu → Show encryption key and copy it to your password manager. If the original system and the kit are both gone, the encrypted backup cannot be recovered; there is no official backdoor. See Chapter 22 for general restore troubleshooting.
FAQ
Where should I store backups?
How often should I create a backup?
Should I enable encryption? What if I forget the password?
Can I inspect old conversations inside a backup?
.tar archive and look under data/pi-agent/sessions/ for the .jsonl files. Each line is a JSON message that a text editor can display. You do not need to restore all of Home Assistant merely to recover an old prompt. Warning: the extracted files contain private conversation text. Delete them securely when you finish and do not leave them on a shared desktop.Can I restore only Pi Agent without changing other Home Assistant settings?
Does the backup include the rclone Google Drive token?
rclone.conf is stored under /data/pi-agent/rclone/, so a Pi Agent backup includes its plaintext OAuth refresh token. Encrypt every backup containing it. If an unencrypted archive leaks, revoke rclone under connected apps in your Google Account, then repeat the authorization flow in Chapter 19.