LocalAI’s models are large downloads, and its configuration is the set of files that describe them. Losing either means downloading and reconfiguring everything again. The install docs say the Compose file keeps models, backends, settings and data in named volumes — those volumes are what you back up.
Stop, then copy
docker compose down
docker run --rm -v localai-models:/models -v localai-configuration:/configuration -v localai-data:/data -v "$PWD/backup:/backup" alpine tar czf /backup/localai-backup.tar.gz /models /configuration /data
Stopping first matters: copying while LocalAI is writing a model download or a settings file can give you a half-written copy. The four volumes are localai-models, localai-backends, localai-data and localai-configuration; include the backends volume too if you installed custom backends. If you installed with the binary instead of Docker, back up the models folder and configuration folder on disk instead — the same rule applies: stop LocalAI first.
Store the copy off the machine
Move the archive to another drive or machine. A backup on the same disk protects against a bad upgrade, not against a dead disk. After a restore, start LocalAI and check the Models page lists the same models before you delete the archive.
| Check | What you should see | If you do not see it |
|---|---|---|
| Container stopped | docker compose down finished before the copy | Copying a running server risks a half-written backup |
| Archive exists | The backup file is non-empty and recent | The volume names were wrong — list them with docker volume ls |
| Restore works | After a test restore, the same models appear | The archive was never tested — an untested backup is a hope, not a backup |
Expected result. We checked the LocalAI install docs for the four named volumes and the docker compose down behaviour. We did not run Docker or LocalAI, so the backup command above is UNTESTED on this machine — confirm your volume names with docker volume ls before running it.
Limits
A backup restores files, not a running service: you still need Docker and the same Compose file to start from it. Model files are large, so the archive will be large too — budget the disk space before you start.
Sources
- LocalAI Install — Container: compose file keeps models, backends, settings and data in named volumes; docker compose down stops LocalAI and keeps the volumes; down -v deletes the volumes
- LocalAI Setting Up Models — models are installed into the models directory
Sources checked 2026-11-28.
