-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackupConda.sh
executable file
·50 lines (44 loc) · 1.2 KB
/
backupConda.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
RCFILE="$(dirname $(readlink -f $0))/backup.rc"
if [[ -z $AWSCMD || -z $TARGET_TYPE || -z $TARGET_LOCATION || -z $TEMPDIR ]] ; then
if [[ -f "$RCFILE" ]] ; then
source "$RCFILE"
else
echo "Configuration file $RCFILE not found, exiting..."
exit 1
fi
fi
echo "Backing up conda configurations"
if [[ -z CONDA_ROOT ]] ; then
echo "CONDA_ROOT is not defined in backup.user.rc"
echo "Cannot backup conda"
exit 1
fi
ACTIVATE="$CONDA_ROOT/bin/activate"
if [ -z $CONDA_EXE ]
then
if [ -f $ACTIVATE ]
then
source $ACTIVATE
else
echo "can't find $ACTIVATE"
exit 1
fi
fi
for env in $(conda env list | tail --lines=+3 | grep -v "\\" awk '{print $1}')
do
SUBDIR=$(mksubdir $env)
echo Processing $env
echo -e "\tExport full environenment"
conda env export --name $env > ${SUBDIR}/${env}-full.yaml
echo -e "\tExport short environenment"
conda env export --from-history --name $env > ${SUBDIR}/${env}.yaml
echo -e "\tExport specs"
conda list --explicit --name ${env} > ${SUBDIR}/${env}-dependencies.txt
HISTORY="${CONDA_ROOT}/envs/${env}/conda-meta/history"
if [[ -f $HISTORY ]] ; then
echo -e "\tCopy history"
cp $HISTORY ${SUBDIR}/${env}-history.txt
fi
done
commit conda Configurations