Update gauntmta_backup.sh
This commit is contained in:
@@ -1,23 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#We can work out if the day of the week with date +%a Mon Tue Wed Thu Fri Sat Sun
|
# Variables
|
||||||
DATE=$(date +%Y%m%d-%H%M%S)
|
DATE=$(date +%Y%m%d-%H%M%S)
|
||||||
BACKUP_DIR=/backups
|
BACKUP_DIR=/backups
|
||||||
SNAR=${BACKUP_DIR}/GauntMTA.snar
|
DIRS_TO_BACKUP="/etc /opt /root /home /var"
|
||||||
TAR=${BACKUP_DIR}/GauntMTA Backup ${DATE}.tgz
|
TAR="${BACKUP_DIR}/GauntMTA Backup ${DATE}.tgz"
|
||||||
|
|
||||||
#If it is Monday we need to make sure that we start with a new snar file to ensure full #backup
|
# pre backup commands
|
||||||
#If the snar file is there it is renamed with a date extension of the previous Monday
|
crontab -l > /root/crontab.txt
|
||||||
if [ $(date +%a) = 'Mon' ]; then
|
|
||||||
test -e ${SNAR} ${SNAR}.$(date --date '7 days ago' +%F)
|
|
||||||
fi
|
|
||||||
#tar -cvpzSg "${SNAR}" -f "${TAR}" --exclude="${BACKUP_DIR}" --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys --exclude=/run --exclude=/media --exclude=/var/cache/apt/archives --one-file-system /
|
|
||||||
|
|
||||||
tar -cvpSzg "${SNAR}" -f "${TAR}" --exclude="${BACKUP_DIR}" --one-file-system /
|
# create the backup
|
||||||
|
tar -cpSzf "${TAR}" --exclude="${BACKUP_DIR}" --exclude=/var/cache --exclude=/var/mail ${DIRS_TO_BACKUP}
|
||||||
|
|
||||||
|
# sync the backup directory to seafile
|
||||||
|
rclone sync /backups/ seafile:
|
||||||
|
|
||||||
|
# only keep 14 copies on local disk, seafile will keep deleted history
|
||||||
|
# https://stackoverflow.com/questions/25785/delete-all-but-the-most-recent-x-files-in-bash
|
||||||
|
ls -tp | grep -v '/$' | tail -n +15 | xargs -I {} rm -- {}
|
||||||
|
|
||||||
|
|
||||||
|
:'
|
||||||
# this is so ugly, need a better solution for what programs are installed/used and their configurations.
|
# this is so ugly, need a better solution for what programs are installed/used and their configurations.
|
||||||
# Programs that are installed:
|
# Programs that are installed:
|
||||||
# postfix
|
# postfix
|
||||||
# spamassians
|
# spamassians
|
||||||
|
# opendkim
|
||||||
|
# opendkim-tools
|
||||||
|
# openvpn
|
||||||
# certbot (letsencrypt)
|
# certbot (letsencrypt)
|
||||||
|
|
||||||
|
|
||||||
@@ -549,4 +558,5 @@ xinetd install
|
|||||||
xz-utils install
|
xz-utils install
|
||||||
zabbix-agent install
|
zabbix-agent install
|
||||||
zabbix-release install
|
zabbix-release install
|
||||||
zlib1g:amd64 install
|
zlib1g:amd64 install
|
||||||
|
'
|
||||||
Reference in New Issue
Block a user