Hermes Agent Backup & Restore: Full Migration Guide
In this article
This guide walks you through backing up, migrating, and restoring a Hermes agent, including its profiles, configuration, and state. You'll learn how to create a complete backup, move it to a new machine, and restore it so your agent works exactly as before. This is essential when upgrading hardware, moving to a server, or recovering from a failure.
What You'll Need
- Access to the terminal or command line on both the source and destination machines.
- Sufficient storage space for the backup archive (typically a few MB per agent).
- If migrating to a different OS, ensure the same Hermes agent version is installed on the destination.
- Optional: A USB drive, network share, or cloud storage for transferring the backup file.
Step-by-Step
1. Locate the Hermes Agent Data Directory
First, find where Hermes stores its profiles, configuration, and state. The default location depends on your operating system:
- Linux:
~/.hermes/or/etc/hermes/depending on installation method. - macOS:
~/Library/Application Support/Hermes/ - Windows:
%APPDATA%\Hermes\orC:\ProgramData\Hermes\for system-wide installs.
If you're unsure, run hermes config path in the terminal to get the exact location.
2. Stop the Hermes Agent
Before backing up, stop the agent to ensure all files are in a consistent state. Use the service manager or the agent's own stop command:
- systemd (Linux):
sudo systemctl stop hermes-agent - macOS launchd:
launchctl unload ~/Library/LaunchAgents/com.hermes.agent.plist - Windows Service:
net stop HermesAgent - If running in a terminal, press
Ctrl+Cto stop gracefully.
3. Create a Compressed Archive
Navigate to the parent directory of the Hermes data folder and create a tar archive (or zip on Windows). For example, on Linux/macOS:
cd ~
tar -czf hermes-backup-$(date +%Y%m%d).tar.gz .hermes/
On Windows (PowerShell):
Compress-Archive -Path $env:APPDATA\Hermes\* -DestinationPath hermes-backup.zip
This archive now contains all profiles, settings, logs, and state data.
4. Verify the Backup Archive
List the contents of the archive to confirm it includes the expected files:
tar -tzf hermes-backup-20250101.tar.gz | head
Check that the profiles/ directory and config.yaml (or similar) are present. If anything is missing, repeat the backup after ensuring the agent is fully stopped.
5. Transfer the Backup to the Destination Machine
Copy the archive to the new machine using scp, rsync, a USB drive, or cloud storage. For example:
scp hermes-backup-20250101.tar.gz user@new-server:/tmp/
6. Install Hermes Agent on the Destination (if not already)
Ensure the same version of Hermes is installed on the new machine. Use the official installer or package manager. Do not start the agent yet.
7. Restore the Backup
On the destination machine, stop the agent if it's running, then extract the archive into the appropriate data directory. For Linux/macOS:
cd ~
tar -xzf /tmp/hermes-backup-20250101.tar.gz
For Windows, use Expand-Archive to the correct path. Make sure the extracted files land in the same relative structure (e.g., .hermes/ inside the home directory).
8. Adjust Permissions (Linux/macOS)
After extraction, ensure the agent user owns the files:
sudo chown -R $(whoami) ~/.hermes/
9. Start the Hermes Agent
Start the agent using the same method as before (systemctl, launchctl, service, or terminal). Check the logs to confirm it starts without errors.
10. Validate the Migration
Run a simple command like hermes profile list to see your profiles. Send a test message to the agent to ensure it responds with the expected behavior. If you have multiple profiles, verify each one loads correctly.
Common Mistakes
- Backing up while the agent is running: This can result in corrupted state files. Always stop the agent first.
- Restoring to the wrong directory: Make sure the archive is extracted to the exact location where Hermes expects its data. A wrong path means the agent won't see the profiles.
- Forgetting to install the same version: Version mismatches can cause config schema errors. Check the version with
hermes --versionon both machines. - Ignoring file permissions: On Linux/macOS, if the agent runs under a different user, it may not read the restored files. Always set ownership correctly.
- Not verifying the backup: A backup that's incomplete is worse than none. Always list the archive contents before transferring.
Tips
- Schedule regular backups using cron or Task Scheduler to avoid data loss.
- Keep the last few backups (e.g., rotate by date) so you can roll back to an earlier state if needed.
- If you're migrating between different OSes, check for path differences in config files (e.g., Windows uses backslashes). Edit the config after restore if necessary.
- Use a version control system (like git) for your profile definitions if they are text-based, to track changes over time.
- Test the restore process on a staging machine before doing it on production.
Troubleshooting
Agent doesn't start after restore
Check the logs (usually in ~/.hermes/logs/) for errors. Common causes: missing dependencies, wrong Python version, or corrupted state. Try deleting the state/ folder (if present) and restarting—the agent will recreate it.
Profiles missing after restore
Verify the archive contained the profiles/ directory. If not, you may have backed up the wrong folder. Also check that the agent's config points to the correct profiles directory.
Permission denied errors
On Linux/macOS, run chown -R as shown in Step 8. On Windows, ensure the service account has full control over the data folder.
Configuration errors (e.g., YAML parse errors)
This often happens when the config file was edited on a different OS and line endings changed. Use a tool like dos2unix to convert line endings, or re-edit the file on the new machine.
Agent connects but doesn't respond correctly
Check that any API keys or tokens in the config are still valid and that the agent's network settings (proxy, firewall) are correct for the new environment.
Frequently Asked Questions
Can I back up only the profiles without the entire agent state?
Yes, you can just archive the profiles/ directory. However, you'll lose conversation history and learned data. For a full migration, include everything.
Does the backup include API keys or secrets?
Yes, the config file typically contains API keys and tokens. Treat the backup as sensitive data—encrypt it if storing in the cloud.
Can I restore to a different OS (e.g., from Windows to Linux)?
Yes, but you may need to adjust file paths and line endings in the config. The profiles themselves are usually portable.
How often should I back up?
It depends on how often your profiles or state change. For active agents, daily backups are recommended; for static ones, weekly is fine.
What if I don't have a backup and the agent breaks?
You may have to recreate profiles manually. Check if Hermes has a built-in export command (e.g., hermes export) that can generate a portable file.
Is it safe to edit the config file directly?
Yes, but make a backup first. A syntax error will prevent the agent from starting. Use a YAML linter to validate changes.