timetracker/year-pack.sh

24 lines
486 B
Bash
Raw Permalink Normal View History

2017-12-08 16:16:19 -05:00
#!/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
2017-12-08 16:16:19 -05:00
MONTH=$(( $(date +%m) - 1 ))
if [ "x$1" == "x" ]
then
YEAR=$(( $(date +%Y) - 1))
2018-08-09 11:55:23 -04:00
ONESET=true
2017-12-08 16:16:19 -05:00
else
YEAR=$1
fi
2018-08-09 11:55:23 -04:00
echo "Tarring up for year ${YEAR}..."
2017-12-08 16:16:19 -05:00
if [ $MONTH -eq 0 ];
then
MONTH=12
2018-08-09 11:55:23 -04:00
if [[ ! ${ONESET} ]]; then
YEAR=$(( $YEAR - 1))
fi
2017-12-08 16:16:19 -05:00
fi
2018-08-09 11:55:23 -04:00
tar -cvJf $YEAR.tar $YEAR-*.tar.xz --remove-files
2017-12-08 16:16:19 -05:00