From ed7306c88b6ee3a87967be6aac64bb32140e156f Mon Sep 17 00:00:00 2001 From: Gaurav C Date: Fri, 5 Feb 2016 17:35:30 +0100 Subject: [PATCH 1/2] Cron for routine backups --- backup.sh | 2 +- run.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index de53da1..359acea 100755 --- a/backup.sh +++ b/backup.sh @@ -1,5 +1,5 @@ #!/bin/bash - +export PATH=$PATH:/usr/bin:/usr/local/bin:/bin # Get timestamp : ${BACKUP_SUFFIX:=.$(date +"%Y-%m-%d-%H-%M-%S")} readonly tarball=$BACKUP_NAME$BACKUP_SUFFIX.tar.gz diff --git a/run.sh b/run.sh index fed4e84..8af6650 100755 --- a/run.sh +++ b/run.sh @@ -5,3 +5,10 @@ if [[ "$RESTORE" == "true" ]]; then else ./backup.sh fi + +if [ -n "$CRON_TIME" ]; then + echo "${CRON_TIME} /backup.sh >> /dockup.log 2>&1" > /crontab.conf + crontab /crontab.conf + echo "=> Running dockup backups as a cronjob for ${CRON_TIME}" + exec cron -f +fi From 7d8539a9c792abc64220d2fcf869caa38a227662 Mon Sep 17 00:00:00 2001 From: Gaurav C Date: Fri, 5 Feb 2016 17:35:38 +0100 Subject: [PATCH 2/2] Removing space --- backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index 359acea..5b1a87f 100755 --- a/backup.sh +++ b/backup.sh @@ -9,7 +9,7 @@ tar czf $tarball $BACKUP_TAR_OPTION $PATHS_TO_BACKUP # Create bucket, if it doesn't already exist BUCKET_EXIST=$(aws s3 ls | grep $S3_BUCKET_NAME | wc -l) -if [ $BUCKET_EXIST -eq 0 ]; +if [ $BUCKET_EXIST -eq 0 ]; then aws s3 mb s3://$S3_BUCKET_NAME fi