timetracker/year-pack.sh

25 lines
630 B
Bash
Raw Permalink Normal View History

#!/bin/bash
PATH=/Users/tblancher/homebrew/opt/coreutils/libexec/gnubin:/Users/tblancher/homebrew/opt/gnu-tar/libexec/gnubin:/Users/tblancher/bin:/Users/tblancher/homebrew/bin:/Users/tblancher/homebrew/sbin:/Users/tblancher/gem/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/sbin:/usr/sbin:/Users/tblancher/bin
MONTH=$(( $(date +%m) - 1 ))
if [[ -z "$1" ]]
then
YEAR=$(( $(date +%Y) - 1))
ONESET=true
else
YEAR=$1
fi
echo "Tarring up for year ${YEAR}..."
if [ $MONTH -eq 0 ];
then
MONTH=12
if [[ ! ${ONESET} ]]; then
YEAR=$(( YEAR - 1))
fi
fi
tar -cvJf "$YEAR.tar" $YEAR-*.tar.xz --remove-files