-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·39 lines (32 loc) · 945 Bytes
/
setup.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
35
36
37
38
39
#!/bin/bash
# The setup script authored by TADOKORO Saneyuki <[email protected]>
cd $(dirname $0)
if ! [ -f ~/.aws/credentials ]; then
cat <<EOF > ~/.aws/credentials
[default]
aws_access_key_id = $AWS_ACCESS_KEY_ID
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY
EOF
fi
if ! [ -f /etc/cron.d/backup ]; then
CRON_MINUTE=${CRON_MINUTE:-*}
CRON_HOUR=${CRON_HOUR:-*}
CRON_DOM=${CRON_DOM:-*}
CRON_MONTH=${CRON_MONTH:-*}
CRON_WEEK=${CRON_WEEK:-*}
MAX_BACKUPS=${MAX_BACKUPS:-20}
cat <<EOF > /etc/cron.d/backup
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/src
S3_BUCKET=$S3_BUCKET
S3_DIR=$S3_DIR
AWS_REGION=$AWS_REGION
MAX_BACKUPS=$MAX_BACKUPS
# m h dom mon dow user command
$CRON_MINUTE $CRON_HOUR $CRON_DOM $CRON_MONTH $CRON_WEEK root backup.sh archive $BACKUP_TARGET && backup.sh clean-old && backup.sh sync
#
EOF
fi
/src/backup.sh rev-sync
crontab /etc/cron.d/backup
cron && tail -f /var/log/cron.log