-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from silinternational/develop
Remove rsyslog and Logentries
- Loading branch information
Showing
8 changed files
with
94 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
FROM alpine:3.11 | ||
|
||
RUN apk update \ | ||
&& apk add --no-cache \ | ||
rsyslog rsyslog-tls \ | ||
ca-certificates openssl \ | ||
bash \ | ||
&& update-ca-certificates | ||
|
||
COPY dockerbuild/rsyslog.conf /etc/rsyslog.conf | ||
|
||
RUN wget https://raw.githubusercontent.com/silinternational/runny/0.2/runny \ | ||
-O /usr/local/bin/runny \ | ||
&& chmod +x /usr/local/bin/runny | ||
&& apk add --no-cache bash | ||
|
||
ARG restic_ver=0.9.6 | ||
|
||
RUN wget https://github.com/restic/restic/releases/download/v${restic_ver}/restic_${restic_ver}_linux_amd64.bz2 \ | ||
-O /tmp/restic.bz2 \ | ||
RUN wget -O /tmp/restic.bz2 \ | ||
https://github.com/restic/restic/releases/download/v${restic_ver}/restic_${restic_ver}_linux_amd64.bz2 \ | ||
&& bunzip2 /tmp/restic.bz2 \ | ||
&& chmod +x /tmp/restic \ | ||
&& mv /tmp/restic /usr/local/bin/restic | ||
|
||
COPY application/ /data/ | ||
WORKDIR /data | ||
|
||
ENTRYPOINT ["./entrypoint.sh"] | ||
CMD ["crond -f"] | ||
CMD ["./entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,53 @@ | ||
#!/usr/bin/env sh | ||
|
||
logger -p user.info "Started backup..." | ||
STATUS=0 | ||
|
||
echo "restic-backup-restore: backup: Started" | ||
echo "restic-backup-restore: Backing up ${SOURCE_PATH}" | ||
|
||
start=$(date +%s) | ||
runny /usr/local/bin/restic backup --host ${RESTIC_HOST} --tag ${RESTIC_TAG} ${RESTIC_BACKUP_ARGS} ${SOURCE_PATH} | ||
/usr/local/bin/restic backup --host ${RESTIC_HOST} --tag ${RESTIC_TAG} ${RESTIC_BACKUP_ARGS} ${SOURCE_PATH} || STATUS=$? | ||
end=$(date +%s) | ||
|
||
logger -p user.info "Backup completed in $(expr ${end} - ${start}) seconds." | ||
if [ $STATUS -ne 0 ]; then | ||
echo "restic-backup-restore: FATAL: Backup returned non-zero status ($STATUS) in $(expr ${end} - ${start}) seconds." | ||
exit $STATUS | ||
else | ||
echo "restic-backup-restore: Backup completed in $(expr ${end} - ${start}) seconds." | ||
fi | ||
|
||
start=$(date +%s) | ||
runny /usr/local/bin/restic forget --host ${RESTIC_HOST} ${RESTIC_FORGET_ARGS} --prune | ||
/usr/local/bin/restic forget --host ${RESTIC_HOST} ${RESTIC_FORGET_ARGS} --prune || STATUS=$? | ||
end=$(date +%s) | ||
|
||
logger -p user.info "Backup pruning completed in $(expr ${end} - ${start}) seconds." | ||
if [ $STATUS -ne 0 ]; then | ||
echo "restic-backup-restore: FATAL: Backup pruning returned non-zero status ($STATUS) in $(expr ${end} - ${start}) seconds." | ||
exit $STATUS | ||
else | ||
echo "restic-backup-restore: Backup pruning completed in $(expr ${end} - ${start}) seconds." | ||
fi | ||
|
||
start=$(date +%s) | ||
runny /usr/local/bin/restic check | ||
/usr/local/bin/restic check || STATUS=$? | ||
end=$(date +%s) | ||
|
||
logger -p user.info "Repository check completed in $(expr ${end} - ${start}) seconds." | ||
if [ $STATUS -ne 0 ]; then | ||
echo "restic-backup-restore: FATAL: Repository check returned non-zero status ($STATUS) in $(expr ${end} - ${start}) seconds." | ||
exit $STATUS | ||
else | ||
echo "restic-backup-restore: Repository check completed in $(expr ${end} - ${start}) seconds." | ||
fi | ||
|
||
start=$(date +%s) | ||
runny /usr/local/bin/restic unlock | ||
/usr/local/bin/restic unlock || STATUS=$? | ||
end=$(date +%s) | ||
|
||
logger -p user.info "Repository unlock completed in $(expr ${end} - ${start}) seconds." | ||
if [ $STATUS -ne 0 ]; then | ||
echo "restic-backup-restore: FATAL: Repository unlock returned non-zero status ($STATUS) in $(expr ${end} - ${start}) seconds." | ||
exit $STATUS | ||
else | ||
echo "restic-backup-restore: Repository unlock completed in $(expr ${end} - ${start}) seconds." | ||
fi | ||
|
||
logger -p user.info "...completed backup." | ||
echo "restic-backup-restore: backup: Completed" | ||
exit $STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
#!/usr/bin/env sh | ||
|
||
if [ "${LOGENTRIES_KEY}" ]; then | ||
sed -i /etc/rsyslog.conf -e "s/LOGENTRIESKEY/${LOGENTRIES_KEY}/" | ||
rsyslogd | ||
sleep 10 # ensure rsyslogd is running before we may need to send logs to it | ||
else | ||
logger -p user.error "Missing LOGENTRIES_KEY environment variable" | ||
fi | ||
STATUS=0 | ||
|
||
case "${FSBACKUP_MODE}" in | ||
init|backup|restore) | ||
/data/${FSBACKUP_MODE}.sh || STATUS=$? | ||
;; | ||
*) | ||
echo restic-backup-restore: FATAL: Unknown FSBACKUP_MODE: ${FSBACKUP_MODE} | ||
exit 1 | ||
esac | ||
|
||
# default to every day at 2 am when no schedule is provided | ||
echo "${CRON_SCHEDULE:=0 2 * * *} runny /data/${FSBACKUP_MODE}.sh" >> /etc/crontabs/root | ||
if [ $STATUS -ne 0 ]; then | ||
echo restic-backup-restore: Non-zero exit: $STATUS | ||
fi | ||
|
||
runny $1 | ||
exit $STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
#!/usr/bin/env sh | ||
|
||
logger -p user.info "Started Restic repository initialization..." | ||
STATUS=0 | ||
|
||
echo "restic-backup-restore: init: Started" | ||
|
||
start=$(date +%s) | ||
runny /usr/local/bin/restic init | ||
/usr/local/bin/restic init || STATUS=$? | ||
end=$(date +%s) | ||
|
||
logger -p user.info "Repository initialization completed in $(expr ${end} - ${start}) seconds." | ||
if [ $STATUS -ne 0 ]; then | ||
echo "restic-backup-restore: FATAL: Repository initialization returned non-zero status ($STATUS) in $(expr ${end} - ${start}) seconds." | ||
exit $STATUS | ||
else | ||
echo "restic-backup-restore: Repository initialization completed in $(expr ${end} - ${start}) seconds. | ||
fi | ||
logger -p user.info "...completed repository initialization." | ||
echo "restic-backup-restore: init: Completed" | ||
exit $STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
#!/usr/bin/env sh | ||
|
||
logger -p user.info "Restoring ${RESTIC_RESTORE_ID}..." | ||
STATUS=0 | ||
|
||
echo "restic-backup-restore: restore: Started" | ||
echo "restic-backup-restore: Restoring ${RESTIC_RESTORE_ID} to ${TARGET_PATH}" | ||
|
||
start=$(date +%s) | ||
runny /usr/local/bin/restic restore ${RESTIC_RESTORE_ID} --host ${RESTIC_HOST} --tag ${RESTIC_TAG} --target ${TARGET_PATH} | ||
/usr/local/bin/restic restore ${RESTIC_RESTORE_ID} --host ${RESTIC_HOST} --tag ${RESTIC_TAG} --target ${TARGET_PATH} || STATUS=$? | ||
end=$(date +%s) | ||
|
||
logger -p user.info "Restoration completed in $(expr ${end} - ${start}) seconds." | ||
if [ $STATUS -ne 0 ]; then | ||
echo "restic-backup-restore: FATAL: Restore returned non-zero status ($STATUS) in $(expr ${end} - ${start}) seconds." | ||
exit $STATUS | ||
else | ||
echo "restic-backup-restore: Restore completed in $(expr ${end} - ${start}) seconds." | ||
fi | ||
|
||
start=$(date +%s) | ||
runny /usr/local/bin/restic unlock | ||
/usr/local/bin/restic unlock || STATUS=$? | ||
end=$(date +%s) | ||
|
||
logger -p user.info "Repository unlock completed in $(expr ${end} - ${start}) seconds." | ||
if [ $STATUS -ne 0 ]; then | ||
echo "restic-backup-restore: FATAL: Repository unlock returned non-zero status ($STATUS) in $(expr ${end} - ${start}) seconds." | ||
exit $STATUS | ||
else | ||
echo "restic-backup-restore: Repository unlock completed in $(expr ${end} - ${start}) seconds." | ||
fi | ||
|
||
logger -p user.info "...completed restore." | ||
echo "restic-backup-restore: restore: Completed" | ||
exit $STATUS |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters