#!/bin/bash
set -e
# also called from /etc/cron.d/lino_backup
cd /usr/local/django/cpas_eupen
umask 0007  # new files writable for other group members
. env/bin/activate
pip freeze > requirements.txt
if [ -d snapshot ]
  then
    # rmdir --ignore-fail-on-non-empty snapshot
    rm -r snapshot
fi
python manage.py dump2py snapshot
mysqldump -u django --password=pwd dsbe_eupen > snapshot/dump.sql
if [ -f snapshot.zip ]
  then
    rm snapshot.zip
fi
zip -r snapshot.zip snapshot
zip -r snapshot.zip fixtures
zip -r snapshot.zip beid_collect
zip -r snapshot.zip media/webdav
zip snapshot.zip *.py *.sh requirements.txt
