#!/bin/bash for file in /var/roothome/.config/bash/module/*.sh; do source "${file}" done dow=$(/usr/bin/date +%u) # current day of week number. date=$(/usr/bin/date +%Y%m%d%H%M) # date stamp. path_src="/var/mnt/storage/hot" # backup src location. path_mount="/var/mnt/storage/cold_1" # backup mount location. path_backup="${path_mount}/backup" # backup dir location. path_docker="${path_backup}/home" # docker backup location. path_media="/var/mnt/storage/cold_1/media /var/mnt/storage/cold_2/media" # media paths. # Check if backup drive is mounted. if [ ! -f "${path_mount}"/.mount ]; then echo "Backup : ${path_mount} not mounted!" notify "Backup : ${path_mount} not mounted!" exit 1 fi # Check if hot storage is mounted. if [ ! -f "${path_src}"/.mount ]; then echo "Backup : ${path_src} not mounted!" notify "Backup : ${path_src} not mounted!" exit 1 fi # Tweak bash. shopt -s globstar shopt -s dotglob # Cd to src storage. builtin cd "${path_src}" # Save media list. /usr/bin/find ${path_media} -type d > ${path_backup}/media/ColdMedia.txt || notify 'Backup : Failed to save media list!' cd ${path_backup}/media/ archive_fast ColdMedia.txt && rm ColdMedia.txt archive_prune ColdMedia 1 cd - # Backup docker. rm ${path_docker}/${dow}_*.tgz archive_fast docker/ && mv Docker_* ${path_docker}/ || notify 'Backup : Failed to save docker!' cd ${path_docker} archive_prune Docker 7 cd - # Notify completion & size. bupsize=$(/usr/bin/du -h ${path_docker}/${dow}_*.tgz | awk '{print $1}') notify_silent "Backup : Complete ${bupsize}." echo "Backup : Complete ${bupsize}."