#!/bin/bash

PATH=/Users/tblancher/homebrew/Cellar/gnu-tar/1.34/libexec/gnubin:/Users/tblancher/homebrew/Cellar/coreutils/9.0/libexec/gnubin:/Users/tblancher/homebrew/bin
MONTH=$(( $(date +%m) - 1 ))
if [ "x$1" == "x" ]
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

