Update gauntmta_backup.sh
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#We can work out if the day of the week with date +%a Mon Tue Wed Thu Fri Sat Sun
|
#We can work out if the day of the week with date +%a Mon Tue Wed Thu Fri Sat Sun
|
||||||
DAY=$(date +%a)
|
DATE=$(date +%a)
|
||||||
FILE=data
|
|
||||||
SNAR=${FILE}.snar
|
SNAR=${FILE}.snar
|
||||||
TAR=~/${FILE}.${DAY}.tar.gz
|
TAR=/backups/GauntMTA.tgz
|
||||||
|
|
||||||
#If it is Monday we need to make sure that we start with a new snar file to ensure full #backup
|
#If it is Monday we need to make sure that we start with a new snar file to ensure full #backup
|
||||||
#If the snar file is there it is renamed with a date extension of the previous Monday
|
#If the snar file is there it is renamed with a date extension of the previous Monday
|
||||||
if [ $DAY = 'Mon' ]
|
if [ $(date +%a) = 'Mon' ]
|
||||||
then
|
then
|
||||||
test -e ~/$SNAR && mv $SNAR ${SNAR}.$(date --date '7 days ago' +%F)
|
test -e ~/$SNAR && mv $SNAR ${SNAR}.$(date --date '7 days ago' +%F)
|
||||||
fi
|
fi
|
||||||
tar -czg ~/$SNAR -f $TAR ~/$FILE
|
tar -czg ~/$SNAR -f $TAR ~/$FILE
|
||||||
|
#tar -cvpSf - --exclude=/backup.tgz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys --exclude=/run --exclude=/media --exclude=/var/cache/apt/archives --exclude=/usr/src/linux-headers* --exclude=/home/*/.gvfs --exclude=/home/*/.cache --exclude=/home/*/.local/share/Trash / | pigz > /backup.tgz
|
||||||
Reference in New Issue
Block a user