Skip to content

Instantly share code, notes, and snippets.

@lesterlo
Last active January 12, 2023 03:54
Show Gist options
  • Save lesterlo/79c085a0a3e8cad33f5d74014a823ad3 to your computer and use it in GitHub Desktop.
Save lesterlo/79c085a0a3e8cad33f5d74014a823ad3 to your computer and use it in GitHub Desktop.
Backup all environment from anaconda
# Place this to your home directories
# If you use this config, all of the envs will store into your home directories
channels: [conda-forge]
auto_activate_base: false
envs_dirs:
- /Users/"YOUR_HOME_DIR"/.conda/envs
#!/bin/sh
# From: https://stackoverflow.com/questions/60508333/export-all-created-conda-environments
for env in $(conda env list | cut -d" " -f1); do
if [[ ${env:0:1} == "#" ]] ; then continue; fi;
conda env export -n $env > ${env}.yml
done
if (( $# == 0 )); then
echo "No arguments provided"
exit 1
fi
if (( $# > 1 )); then
echo "Invalid arguments provided"
exit 1
fi
for entry in "$1"/*.yml
do
echo "Recovering: $entry"
conda env create -f $entry
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment