Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Cron to do routine backups #17

Merged
merged 2 commits into from
Mar 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backup.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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