#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
# set -o xtrace

currentDate=$(date +%Y%m%d)
rootpath="/data/fullbackup/"
backuppath=$rootpath$currentDate

cd $rootpath

printf "\n## Compress backup directory\n" 
printf "\n*********************\n"
printf "compress elapsed time\n" 
#time tar -czf "${currentDate}".tgz "${currentDate}" --remove-files 
time tar -cf - "${currentDate}" --remove-files |pigz -p 64 > "${currentDate}".tgz
printf "\n*********************\n"
printf "\nNow time is %s\n" "$(date)"
printf "\nBackup Finished! \n"
printf "\n## Today's compressed backup file volume is:\n"
du -sh "${currentDate}".tgz
