by danduran on Development 4 min read, Comments: 0 (Add Your Comment!)

How to back up, downgrade, and restore Ollama on macOS without losing models or data

TL;DR:

The guide covers backing up models and settings, uninstalling the current version, reinstalling a specific version, restoring backups, and testing functionality with a sample prompt.

How to back up, downgrade, and restore Ollama on macOS without losing models or data

1. BACKUP: Protect Your Models and Configuration

Ollama stores its models and metadata in ~/.ollama/models. To ensure you don’t lose models during a downgrade or reinstallation:

Step 1.1: Check Existing Models

Run the following command to list all models currently available in Ollama:

ollama list

Example output:

NAME                               ID              SIZE     PROCESSOR         UNTIL              
jimscard/blackhat-hacker:latest    aec42c0a7ff1    11 GB    3%/97% CPU/GPU    4 minutes from now 

This confirms the models you want to preserve.


Step 1.2: Backup the Models Directory

The models and metadata are stored in ~/.ollama/models/. To back them up:

cp -r ~/.ollama/models ~/Desktop/ollama_models_backup

This creates a backup on your desktop (~/Desktop/ollama_models_backup), which includes:
- blobs: Model files
- manifests: Metadata and versioning information


Step 1.3: Backup Open WebUI Data (If Applicable)

If you’re using Open WebUI with Ollama, backup its settings and tools:

cp -r ~/.openwebui ~/Desktop/openwebui_backup

2. UNINSTALL: Remove the Current Ollama Version

To downgrade Ollama, first uninstall the existing version.

Step 2.1: Uninstall Ollama

Run the following command to remove Ollama:

brew uninstall ollama

Step 2.2: Confirm Removal

Ensure that Ollama is completely uninstalled:

ollama --version

This should output an error: command not found.


3. INSTALL: Downgrade to a Specific Ollama Version

Step 3.1: Install a Specific Version via Homebrew

Check if the desired version is available in Homebrew:

brew info ollama

If the desired version is listed, install it:

brew install [email protected]

Step 3.2: Download Manually from GitHub

If the version isn’t available in Homebrew, manually download the .dmg file from the Ollama GitHub Releases page:
1. Navigate to the desired version (e.g., 0.4.5).
2. Download the .dmg installer for macOS.
3. Install the downloaded version by opening the .dmg and following the instructions.


4. RESTORE: Ensure Models and Configurations Are Intact

Step 4.1: Verify Models

After reinstalling, check if Ollama recognizes your existing models:

ollama list
  • If the list is empty, restore the backup:
rm -r ~/.ollama/models
cp -r ~/Desktop/ollama_models_backup ~/.ollama/models

Step 4.2: Verify Open WebUI Integration

If using Open WebUI, ensure it can still access Ollama:
1. Restart Open WebUI:

openwebui serve
  1. Test a model by invoking it from Open WebUI.

5. TEST: Verify Functionality

Step 5.1: Run a Model

Test a model to confirm proper functionality:

ollama run jimscard/blackhat-hacker:latest --prompt "Hello!"

Step 5.2: Monitor Performance

Check for slowdowns or issues:
- Open the macOS Activity Monitor.
- Look for high CPU, GPU, or memory usage by ollama.

Step 5.3: Flash Attention

If Flash Attention is supported in your version of Ollama and models, it should be automatically enabled. You can confirm via logs:

cat ~/.ollama/logs/* | grep -i flash_attention

6. OPTIONAL: Pin the Installed Version

To prevent Homebrew from automatically upgrading Ollama:

brew pin ollama

7. TROUBLESHOOTING

Issue 1: Port Conflict

If you encounter Error: listen tcp 127.0.0.1:11434: bind: address already in use, a process is already using the port.

Solution: Stop the Conflicting Process

  1. Find the process using the port:
lsof -i :11434
  1. Kill the process:
kill -9 <PID>

Alternative: Change Port

Run Ollama on a different port:

ollama serve --port 12345

Issue 2: Models Not Recognized

If Ollama doesn’t detect existing models:
1. Restore from backup:

rm -r ~/.ollama/models
cp -r ~/Desktop/ollama_models_backup ~/.ollama/models
  1. Restart Ollama:
ollama serve

Issue 3: Flash Attention Not Working

Flash Attention might not be explicitly configurable in Ollama. If it's not working:
- Ensure your downgraded version supports Flash Attention.
- If not, revert to the latest version:

brew install ollama

8. SUMMARY WORKFLOW

  1. Backup models (~/.ollama/models) and Open WebUI settings (~/.openwebui).
  2. Uninstall Ollama:
brew uninstall ollama
  1. Reinstall a specific version:
brew install [email protected]
  1. Restore models:
cp -r ~/Desktop/ollama_models_backup ~/.ollama/models
  1. Test functionality:
ollama run llama2 --prompt "Hello!"

Let me know if you encounter any roadblocks during the process!

No comments yet. Be the first to comment!