From 144b41bb1f0e09ec6bcd76b28d7e23e8cb089eaa Mon Sep 17 00:00:00 2001 From: Kishan Takoordyal Date: Fri, 19 May 2023 20:42:12 +0000 Subject: [PATCH] Update Section_05/cron.sh, Section_05/backup.sh --- Section_05/backup.sh | 15 +++++++++++++++ Section_05/cron.sh | 8 ++++++++ 2 files changed, 23 insertions(+) create mode 100644 Section_05/backup.sh create mode 100644 Section_05/cron.sh 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