-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathentry.sh
64 lines (58 loc) · 1.76 KB
/
entry.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/sh
# Entry point for rsnapshot backup
# This will create the config file (using environment variables),
# a crontab, and start cron
# First part of rsnapshot config
cat > /etc/rsnapshot.conf <<EOF
config_version 1.2
snapshot_root /backup/
no_create_root 1
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
ssh_args -i /ssh-id -o StrictHostKeychecking=no ${BACKUP_SSH_ARGS}
verbose 1
lockfile /var/run/rsnapshot.pid
backup ${BACKUP_SOURCE} ${BACKUP_NAME}/ ${BACKUP_OPTS}
EOF
# create empty crontab for root
# empty file, otherwise the cronjobs will be added with every container start.
> /etc/crontabs/root
# Dynamic parts - depending on the retain settings
# This will also create the crontab
if [ "${BACKUP_HOURLY}" -gt 0 ]
then
echo "retain hourly ${BACKUP_HOURLY}">> /etc/rsnapshot.conf
echo "${CRON_HOURLY} rsnapshot hourly" >> /etc/crontabs/root
fi
if [ "${BACKUP_DAILY}" -gt 0 ]
then
echo "retain daily ${BACKUP_DAILY}">> /etc/rsnapshot.conf
echo "${CRON_DAILY} rsnapshot daily" >> /etc/crontabs/root
fi
if [ "${BACKUP_WEEKLY}" -gt 0 ]
then
echo "retain weekly ${BACKUP_WEEKLY}">> /etc/rsnapshot.conf
echo "${CRON_WEEKLY} rsnapshot weekly" >> /etc/crontabs/root
fi
if [ "${BACKUP_MONTHLY}" -gt 0 ]
then
echo "retain monthly ${BACKUP_MONTHLY}">> /etc/rsnapshot.conf
echo "${CRON_MONTHLY} rsnapshot monthly" >> /etc/crontabs/root
fi
if [ "${BACKUP_YEARLY}" -gt 0 ]
then
echo "retain yearly ${BACKUP_YEARLY}">> /etc/rsnapshot.conf
echo "${CRON_YEARLY} rsnapshot yearly" >> /etc/crontabs/root
fi
# Add the user-provided config file
cat /backup.cfg >> /etc/rsnapshot.conf
# Test the config
CONFIGTEST=$(rsnapshot configtest)
echo "${CONFIGTEST}"
if [ "${CONFIGTEST}" = "Syntax OK" ]
then
# Syntax is OK, start cron
/usr/sbin/crond -f
fi