backup.sh (548B)
1 #!/bin/bash 2 # 3 # backup 4 5 BACKUP_DIR='/mnt/backup' 6 LOG='/var/log/backup.log' 7 stamp="$(date +%Y-%m-%d\ %I:%M\ %p)" 8 9 main() { 10 if df | grep -q "${BACKUP_DIR}"; then 11 [ ! -e "${LOG}" ] && touch "${LOG}" 12 # shellcheck disable=SC3009 13 rsync -aAXHv --delete --exclude={"/mnt/","/proc/","/sys/"} --exclude="media/" / "${BACKUP_DIR}" 14 printf '%s\n' "${stamp} - System backup complete." >> "${LOG}" 15 else printf '%s\n' "${stamp} - ${BACKUP_DIR} is not a mount point. Not backing up system." >> "${LOG}" 16 fi 17 } 18 19 main "${@}"