Created
January 20, 2015 14:50
-
-
Save carsongee/9f64e40656c27885ab61 to your computer and use it in GitHub Desktop.
course backup to git script for edx-platform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script assumes that the git repository is already cloned | |
# App specifics | |
EDXAPP_USER="edxapp" | |
EDXAPP_VENV="/edx/app/edxapp/venvs/edxapp" | |
EDXAPP_DIR="/edx/app/edxapp/edx-platform" | |
# Git specifics | |
export GIT_KEY="/edx/app/course_git_backup/git_backup_deploy" | |
export EXPORT_DIR="/mnt/course_git_backup" | |
SERVICE_VARIANT='cms' | |
git config --global push.default simple | |
# Dump the courses - ignoring output since it is nasty about stderrs that aren't stderrs | |
su - $EDXAPP_USER -s /bin/bash -c "cd $EDXAPP_DIR; SERVICE_VARIANT=$SERVICE_VARIANT $EDXAPP_VENV/bin/python manage.py $SERVICE_VARIANT --settings=aws export_all_courses $EXPORT_DIR" > /dev/null 2>&1 | |
cd $EXPORT_DIR | |
git add . | |
if [ $? -ne 0 ]; then | |
echo "Automated course_git_backup has failed, unable to add" >&2 | |
exit 1 | |
fi | |
git commit -a -m "Automated backup of course xml from cron task at $(date)" | |
if [ $? -ne 0 ]; then | |
echo "Automated course_git_backup has failed, unable to commit." >&2 | |
exit 1 | |
fi | |
ssh-agent bash -c 'ssh-add $GIT_KEY; cd $EXPORT_DIR; git push -q' |& grep -v 'Identity added:' | |
if [ ${PIPESTATUS[0]} -ne 0 ]; then | |
echo "Automated course_git_backup has failed, unable to push" >&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment