#!/bin/bash ####################################################################### #Script Name: all_vm_backup_post #Version: 1.5 #Description: Script to rclone backup to AWS for Debian. #Last Modify Date: 12222024 #Author:Brent Dacus #Email:brent[at]thedacus[dot]net ####################################################################### # Variables # ####################################################################### #local backup locations mailtoaddress="tech@delainhosting.com" mailfromaddress="tech@delainhosting.com" admin=/admin_backups system=/sys_backup host="$(hostname -s)" wom=$((($(date +%-d) - 1) / 7 + 1)) #remote backup dest remote=bb2 bucket="$(hostname -s)"rcbkup #logfile location logfile=/var/log/rclone/aws.log #file location export RCLONE_CONFIG_PASS=/usr/local/bin/passwd.txt #exit if running if [[ $(pidof -x "$(basename "$0")" -o %PPID) ]]; then exit; fi printf "Backing up the %s directory on %s to %s.\n" "$admin" "$host" "$bucket" rclone sync $admin $remote:$bucket/$host$admin/$wom --log-level INFO --log-file $logfile if [ "$?" -eq 0 ]; then rclone check $admin $remote:$bucket/$host$admin/$wom --one-way --log-level INFO --log-file $logfile printf "Backing up Complete.\n" else date >>$logfile mail -s "System backup failed on server $host" -r "$mailfromaddress" "$mailtoaddress" <$logfile fi printf "Backing up the %s directory on %s to %s.\n" "$system" "$host" "$bucket" rclone sync $system $remote:$bucket/$host$system --log-level INFO --log-file $logfile if [ "$?" -eq 0 ]; then rclone check $system $remote:$bucket/$host$system --one-way --log-level INFO --log-file $logfile printf "Backing up Complete.\n" else date >>$logfile mail -s "System backup failed on server $host" -r "$mailfromaddress" "$mailtoaddress" <$logfile fi # reset credentials unset rclone_config_pass exit 0