diff --git a/Section_05/backup.sh b/Section_05/backup.sh new file mode 100644 index 0000000..d2d666c --- /dev/null +++ b/Section_05/backup.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +CODE_PATH="/home/edgeking810/tmpNodeApp" +BACKUP_PATH="/home/edgeking810/backups" + +mkdir -p ${BACKUP_PATH} + +BACKUP_NAME="tmp-node-app-$(date '+%Y-%m-%d_%H-%M-%S').tar.gz" +tar -zcvf ${BACKUP_PATH}/${BACKUP_NAME} ${CODE_PATH} + +# Cleanup backups older than 1 month +find ${BACKUP_PATH} -name "*.tar.gz" -type f -mtime +30 -delete + +echo "Backup Succeeded: ${BACKUP_PATH}/${BACKUP_NAME}" +echo "----------------------------------------------------------------------" diff --git a/Section_05/cron.sh b/Section_05/cron.sh new file mode 100644 index 0000000..d5c9b01 --- /dev/null +++ b/Section_05/cron.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +sudo apt install cron -y +crontab -l + +EDITOR=nano crontab -e +# m h dom mon dow command +*/10 * * * * bash /home/edgeking810/backup.sh | tee -a /tmp/backup-logs.txt