- Export one model
- Backup ALL your models
- Import your backup folder into ollama
- Update your ollama models
I have only tested these two scripts on Windows 11 + Ollama 0.3.8
I am not sure if they will work correctly on Mac or Linux systems.
This is just a free open-source script, I am not responsible for any consequences that may arise from your use of the code.
✨ Check out my other project: Waifu2x-Extension-GUI
Download Export_Model.py
Edit BackUp_Folder
and Ollama_Model_Folder
at the bottom of the file:
#****************************************************************
#****************************************************************
#****************************************************************
# Your ollama model folder:
Ollama_Model_Folder = r"D:\llama\.ollama\models"
# Where you want to back up your models:
BackUp_Folder = r"E:\llama_backup"
#****************************************************************
#****************************************************************
#****************************************************************
model_name = input("Enter model name: ")
Then start Export_Model.py, enter the model name then click Enter
key to start export the model.
It will backup gguf and modelfile into a folder:
Download Backup_ALL_Models.py
Edit BackUp_Folder
and Ollama_Model_Folder
at the bottom of the file:
output_file = f"ModelFile"
#****************************************************************
#****************************************************************
#****************************************************************
# Your ollama model folder:
Ollama_Model_Folder = r"D:\llama\.ollama\models"
# Where you want to back up your models:
BackUp_Folder = r"E:\llama_backup"
#****************************************************************
#****************************************************************
#****************************************************************
create_ollama_model_file(model_name, output_file, BackUp_Folder, Ollama_Model_Folder)
def extract_names(data):
Then start Backup_ALL_Models.py, it will strating to back up all of your models
It will backup gguf and modelfile into a folder:
To avoid unnecessary copying, by default it will skip the model if it already exists in the backup folder
You can turn off this by delete
if os.path.exists(new_folder_path) and os.path.isdir(new_folder_path):
print(f"Model: '{model_name}' already exists in the backup folder, so it will be skipped.")
return
At:
new_folder_path = os.path.join(BackUp_Folder, model_name)
#****************************************************************
#****************************************************************
#****************************************************************
if os.path.exists(new_folder_path) and os.path.isdir(new_folder_path):
print(f"Model: '{model_name}' already exists in the backup folder, so it will be skipped.")
return
#****************************************************************
#****************************************************************
#****************************************************************
if not os.path.exists(new_folder_path):
os.makedirs(new_folder_path)
print(f"Created folder: {new_folder_path}")
Download Import_Models.py
Edit scan_folder
at the bottom of the file:
#****************************************************************
# Your model backup folder:
scan_folder(r'E:\llama_backup')
#****************************************************************
Then start Import_Models.py, it will strating to import all of your model backups into ollama
Download: Update_ALL_Models.py
Then start Update_ALL_Models.py, it will strating to update all of your ollama models using ollama's pull command.
Only the models you downloaded from ollama.com will be updated.