ollama - ✅(Solved) Fix Feature request: add export command and pull -r flag for environment migration [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#14760Fetched 2026-04-08 00:32:00
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

I would like to propose a small CLI feature to make it easier to migrate an Ollama environment between machines.

The idea is to support a workflow similar to pip freeze / pip install -r:

  • ollama export: exports the list of installed models to stdout or a file
  • ollama pull -r <file>: batch pulls models from an “export” file

This would allow users to easily back up and restore their model setup.


Root Cause

I would like to propose a small CLI feature to make it easier to migrate an Ollama environment between machines.

The idea is to support a workflow similar to pip freeze / pip install -r:

  • ollama export: exports the list of installed models to stdout or a file
  • ollama pull -r <file>: batch pulls models from an “export” file

This would allow users to easily back up and restore their model setup.


PR fix notes

PR #13816: cmd: add export command and pull -r flag for environment migration

Description (problem / solution / changelog)

Summary

I would like to propose a small CLI feature to make it easier to migrate an Ollama environment between machines.

The idea is to support a workflow similar to pip freeze / pip install -r:

  • ollama export: exports the list of installed models to stdout or a file
  • ollama pull -r <file>: batch pulls models from an “export” file

This would allow users to easily back up and restore their model setup.


Problem

Today, when moving from one machine to another (e.g., laptop → server, old server → new server), users need to:

  • Manually remember which models they had installed
  • Manually re-run multiple ollama pull commands
  • Potentially forget some models or make mistakes

There is no built-in, reproducible way to “snapshot” the current model list and restore it elsewhere.


Proposed solution

Add two pieces of functionality to the ollama CLI:

1. ollama export

  • Lists installed (local) models using the existing API
  • Outputs a text format that is easy to read and parse
  • Supports writing to stdout or to a file
  • Skips remote/cloud-only models by commenting them out

Example output:

# Ollama models export
# Generated at: 2026-01-21T12:34:56Z
# Use 'ollama pull -r <file>' to restore these models

llama3.1:8b
qwen2.5:7b
# (remote) some-remote-only-model

Example usage:

ollama export
ollama export -o models.txt

2. ollama pull -r <file>

  • Reads a “requirements-like” file line by line
  • Ignores empty lines and lines starting with #
  • For each remaining line, calls the existing pull logic
  • Prints a summary of any failures at the end

Example usage:

# On the source machine
ollama export -o models.txt

# Copy file to target
scp models.txt target:~/

# On the target machine
ollama pull -r models.txt

Benefits

  • Simple environment migration: easy way to mirror an Ollama setup across machines.
  • Backups: users can keep a text file snapshot of their current models.
  • Consistency: follows a very familiar pattern from other ecosystems (e.g. pip, conda).

Implementation notes

I have opened a PR with a concrete implementation and tests:

High-level details:

  • Adds an export subcommand in cmd/cmd.go with a handler that:
    • Uses the existing API client to list models
    • Writes a header and model names to stdout or an output file
    • Comments out remote-only models (can’t be pulled directly)
  • Extends ollama pull with a -r/--requirements flag:
    • When provided, it reads models from a file and pulls them in batch
    • Reuses the existing pull logic to avoid code duplication
  • Includes unit tests for both export and pull -r behaviors.

I’m happy to adjust naming, flags, or behavior to better fit the maintainers’ vision.


Questions for maintainers

  • Is this kind of environment-migration workflow something you’d be open to supporting in core?
  • Are export and pull -r acceptable names/UX, or would you prefer a different interface?
  • Are there any constraints or edge cases (e.g. cloud-only models, future registry changes) that you’d want the design to account for?

Changed files

  • cmd/cmd.go (modified, +152/-4)

Code Example

# Ollama models export
# Generated at: 2026-01-21T12:34:56Z
# Use 'ollama pull -r <file>' to restore these models

llama3.1:8b
qwen2.5:7b
# (remote) some-remote-only-model

---

ollama export
ollama export -o models.txt

---

# On the source machine
ollama export -o models.txt

# Copy file to target
scp models.txt target:~/

# On the target machine
ollama pull -r models.txt
RAW_BUFFERClick to expand / collapse

Feature request: add export command and pull -r flag for environment migration

Summary

I would like to propose a small CLI feature to make it easier to migrate an Ollama environment between machines.

The idea is to support a workflow similar to pip freeze / pip install -r:

  • ollama export: exports the list of installed models to stdout or a file
  • ollama pull -r <file>: batch pulls models from an “export” file

This would allow users to easily back up and restore their model setup.


Problem

Today, when moving from one machine to another (e.g., laptop → server, old server → new server), users need to:

  • Manually remember which models they had installed
  • Manually re-run multiple ollama pull commands
  • Potentially forget some models or make mistakes

There is no built-in, reproducible way to “snapshot” the current model list and restore it elsewhere.


Proposed solution

Add two pieces of functionality to the ollama CLI:

1. ollama export

  • Lists installed (local) models using the existing API
  • Outputs a text format that is easy to read and parse
  • Supports writing to stdout or to a file
  • Skips remote/cloud-only models by commenting them out

Example output:

# Ollama models export
# Generated at: 2026-01-21T12:34:56Z
# Use 'ollama pull -r <file>' to restore these models

llama3.1:8b
qwen2.5:7b
# (remote) some-remote-only-model

Example usage:

ollama export
ollama export -o models.txt

2. ollama pull -r <file>

  • Reads a “requirements-like” file line by line
  • Ignores empty lines and lines starting with #
  • For each remaining line, calls the existing pull logic
  • Prints a summary of any failures at the end

Example usage:

# On the source machine
ollama export -o models.txt

# Copy file to target
scp models.txt target:~/

# On the target machine
ollama pull -r models.txt

Benefits

  • Simple environment migration: easy way to mirror an Ollama setup across machines.
  • Backups: users can keep a text file snapshot of their current models.
  • Consistency: follows a very familiar pattern from other ecosystems (e.g. pip, conda).

Implementation notes

I have opened a PR with a concrete implementation and tests:

High-level details:

  • Adds an export subcommand in cmd/cmd.go with a handler that:
    • Uses the existing API client to list models
    • Writes a header and model names to stdout or an output file
    • Comments out remote-only models (can’t be pulled directly)
  • Extends ollama pull with a -r/--requirements flag:
    • When provided, it reads models from a file and pulls them in batch
    • Reuses the existing pull logic to avoid code duplication
  • Includes unit tests for both export and pull -r behaviors.

I’m happy to adjust naming, flags, or behavior to better fit the maintainers’ vision.


Questions for maintainers

  • Is this kind of environment-migration workflow something you’d be open to supporting in core?
  • Are export and pull -r acceptable names/UX, or would you prefer a different interface?
  • Are there any constraints or edge cases (e.g. cloud-only models, future registry changes) that you’d want the design to account for?

extent analysis

Fix Plan

To implement the proposed solution, follow these steps:

  • Add an export subcommand in cmd/cmd.go with a handler that:
    • Uses the existing API client to list models
    • Writes a header and model names to stdout or an output file
    • Comments out remote-only models
  • Extend ollama pull with a -r/--requirements flag:
    • When provided, it reads models from a file and pulls them in batch
    • Reuses the existing pull logic to avoid code duplication

Example code snippets:

// cmd/cmd.go
func exportCmd() *cobra.Command {
    var output string
    cmd := &cobra.Command{
        Use:   "export",
        Short: "Export installed models to a file",
        Run: func(cmd *cobra.Command, args []string) {
            // List models using existing API client
            models, err := listModels()
            if err!= nil {
                log.Fatal(err)
            }
            // Write header and model names to stdout or output file
            writeModels(models, output)
        },
    }
    cmd.Flags().StringVarP(&output, "output", "o", "", "Output file")
    return cmd
}

func pullCmd() *cobra.Command {
    var requirements string
    cmd := &cobra.Command{
        Use:   "pull",
        Short: "Pull models",
        Run: func(cmd *cobra.Command, args []string) {
            // Check if -r flag is provided
            if requirements!= "" {
                // Read models from file and pull them in batch
                models, err := readModels(requirements)
                if err!= nil {
                    log.Fatal(err)
                }
                pullModels(models)
            } else {
                // Existing pull logic
            }
        },
    }
    cmd.Flags().StringVarP(&requirements, "requirements", "r", "", "Requirements file")
    return cmd
}

// Helper functions
func listModels() ([]string, error) {
    // Implement listing models using existing API client
}

func writeModels(models []string, output string) {
    // Implement writing models to stdout or output file
}

func readModels(requirements string) ([]string, error) {
    // Implement reading models from file
}

func pullModels(models []string) {
    // Implement pulling models in batch
}

Verification

To verify the fix, run the following commands:

  • ollama export to export installed models to stdout
  • ollama export -o models.txt to export installed models to a file
  • ollama pull -r models.txt to pull models from the file

Check that the output is as expected and that the models are pulled correctly.

Extra Tips

  • Make sure to handle errors and edge cases properly, such as cloud-only models and future registry changes.
  • Consider adding unit tests for the

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - ✅(Solved) Fix Feature request: add export command and pull -r flag for environment migration [1 pull requests, 1 participants]