forked from vmakhaev/mongo-s3-backup
-
Notifications
You must be signed in to change notification settings - Fork 3
/
start.sh
executable file
·34 lines (29 loc) · 915 Bytes
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
CRON_SCHEDULE=${CRON_SCHEDULE:-0 1 * * *}
CRON_ENVIRONMENT="
AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-}
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:?"env variable is required"}
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:?"env variable is required"}
MONGO_HOST=${MONGO_HOST:?"env variable is required"}
MONGO_PORT=${MONGO_PORT:-27017}
S3_BUCKET=${S3_BUCKET:?"env variable is required"}
BACKUP_FILENAME_PREFIX=${BACKUP_FILENAME_PREFIX:-mongo_backup}
BACKUP_FILENAME_DATE_FORMAT=${BACKUP_FILENAME_DATE_FORMAT:-%Y%m%d}
"
CRON_COMMAND="/script/backup.sh 1>/var/log/backup_script.log 2>&1"
echo
echo "Configuration"
echo
echo "CRON_SCHEDULE"
echo
echo "$CRON_SCHEDULE"
echo
echo "CRON_ENVIRONMENT"
echo "$CRON_ENVIRONMENT"
# crontab -l > mycron
echo "$CRON_ENVIRONMENT$CRON_SCHEDULE $CRON_COMMAND" >> mycron
crontab mycron
rm mycron
mkfifo /var/log/backup_script.log
cron
tail -f /var/log/backup_script.log