#!/bin/sh
if [ -d DB/.git ]
then
# If there is a GIT repository: use it
cd DB
if [ $(grep -c pyc <.git/info/exclude) -eq 0 ]
then
echo "" >>.git/info/exclude
echo "*.pyc" >>.git/info/exclude
fi
git add .
echo "Night backup" | git commit -a --file -
else
# The saved data directory is hard coded here.
D=$(date +'/DATA/BACKUPS/%Y/%m')
mkdir -p $D
tar -cvf - --exclude='*.pyc' DB/. |
bzip2 -9 >$D/tomuss.$(date '+%Y-%m-%d').tar.bz2
fi 2>LOGS/xxx_backup >&2