Model weights are the least precious part of an Ollama install: they are large, they do not change, and anyone can download them again with ollama pull. What you cannot download again is your own work: the list of what you installed, and the Modelfiles behind the custom models you built, with their system prompts and settings. One tested backup guide puts it as a rule: for Ollama, back up the list and the recipes, not the weights. Its test install held four models using 8.8 GB, all re-downloadable, while the custom models were the part that would have been lost.
Save the list of models
Write the installed list to a file and keep that file with your other configuration:
ollama list > ollama-list.txt
After a rebuild, pull them all again from the list:
awk 'NR>1 {print $1}' ollama-list.txt | xargs -n1 ollama pull
Remove your own custom models from the list first, since they are not in any registry; they come back from their Modelfiles, below. This is a backup of a list, not a move of the model folder: nothing here changes OLLAMA_MODELS or copies the weights directory.
Export each custom model’s Modelfile
A custom Ollama model is a base model plus settings: a system prompt, parameters such as temperature and context size, sometimes a template. The guide’s example custom model is homelab-brief, built from this Modelfile:
FROM llama3.2:3b
PARAMETER temperature 0.2
PARAMETER num_ctx 8192
SYSTEM You answer homelab questions briefly.
ollama create homelab-brief -f Modelfile
Ollama can print a Modelfile for any installed model, so export each custom one and keep the file:
ollama show --modelfile homelab-brief
Keep the Modelfiles you wrote, in a Git repository or with your other configuration, and treat the exported ones as a safety net.
Fix the FROM line before you rebuild
The exported Modelfile has a trap in its first line. It is not FROM llama3.2:3b; it is the path of the weights file on this machine:
FROM /usr/share/ollama/.ollama/models/blobs/sha256-dde5aa3f...
On a new machine that does not have that exact file, creating a model from this Modelfile failed with an error about the blob path. The fix is to change the FROM line back to the base model name and pull that model first:
ollama pull llama3.2:3b
ollama create homelab-brief -f Modelfile
The exported file also includes the base model’s full prompt template and stop tokens, which you did not write and do not need. On Linux the models live in /usr/share/ollama/.ollama/models by default, which is why the exported path points there.
Try it: three checks from backup to restore
| Check | What you should see | What it means |
|---|---|---|
| List saved | ollama-list.txt holds one line per installed model |
You know what to pull again |
| Modelfile exported | ollama show --modelfile homelab-brief prints the system prompt and parameters |
The custom model’s recipe is saved |
| FROM line fixed | The saved Modelfile starts with FROM llama3.2:3b, and ollama create homelab-brief -f Modelfile succeeds after pulling the base model |
The custom model rebuilds on the new machine |
Expected result. We checked the tested backup guide, which gives the list backup and restore commands, the homelab-brief Modelfile, the exported blob-path FROM line, and the fix. We did not back up, delete, or restore any Ollama install on this machine.
Limits
Backing up weights is usually wasteful, but the guide names the exceptions: a slow or metered connection, where pulling tens of gigabytes again takes a day, and models that may disappear from a registry or be replaced under the same name. In those cases copy the whole models directory, both blobs and manifests, with Ollama stopped. Imported GGUF files you got from somewhere else also deserve their original file kept, not just Ollama’s copy. This guide covers Ollama only; chats and settings in a front end such as Open WebUI are a separate backup. We did not test any of this ourselves.
Sources
- Big Iron — Backing Up Your Self-Hosted AI Stack — back up the list and the recipes, not the weights; ollama list and the awk restore; the homelab-brief Modelfile; ollama show –modelfile and the blob-path FROM line that fails on a new machine
- Ollama FAQ — where models are stored: Linux /usr/share/ollama/.ollama/models, macOS ~/.ollama/models, Windows C:\Users\%username%\.ollama\models; OLLAMA_MODELS changes the location
