rattail-fabric2/rattail_fabric2/deploy/backup/backup-everything.mako

44 lines
1 KiB
Plaintext
Raw Normal View History

#!/bin/sh -e
if [ "$1" = "-v" -o "$1" = "--verbose" ]; then
VERBOSE='--verbose'
QUIET=
PROGRESS='--progress'
CONFIG='/srv/envs/${envname}/app/rattail.conf'
else
VERBOSE=
QUIET='--quiet'
PROGRESS=
CONFIG='/srv/envs/${envname}/app/silent.conf'
fi
RATTAIL="/srv/envs/${envname}/bin/rattail --config=$CONFIG $PROGRESS $VERBOSE"
PIP="sudo -H -u ${user} PIP_CONFIG_FILE=/srv/envs/${envname}/pip.conf /srv/envs/${envname}/bin/pip"
# sanity check
if [ "$HOME" != '/root' ]; then
echo ''
echo '$HOME is not /root - please run this as e.g.:'
echo ''
echo ' sudo -H backup-everything [--verbose]'
exit 1
fi
# upgrade pip
$PIP install $QUIET --upgrade pip
# upgrade rattail
cd /srv/envs/${envname}/src/rattail
if [ "$(sudo -H -u ${user} git status --porcelain)" != '' ]; then
sudo -H -u ${user} git status
exit 1
fi
sudo -H -u ${user} git pull $QUIET
find . -name '*.pyc' -delete
$PIP install $QUIET --upgrade --upgrade-strategy eager --editable .
# run backup
cd /srv/envs/${envname}
$RATTAIL backup