Skip to content

Commit

Permalink
Merge pull request #2 from silinternational/develop
Browse files Browse the repository at this point in the history
Changes for v1.0.0
  • Loading branch information
dalenewby authored Feb 11, 2020
2 parents a9d26ab + b5d4f04 commit 16ce005
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ RUN wget https://raw.githubusercontent.com/silinternational/runny/0.2/runny \
-O /usr/local/bin/runny \
&& chmod +x /usr/local/bin/runny

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 \
&& bunzip2 /tmp/restic.bz2 \
&& chmod +x /tmp/restic \
&& mv /tmp/restic /usr/local/bin/restic

COPY application/ /data/
WORKDIR /data

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ Docker image to initialize, backup to, and restore from a Restic repository on A

4. `CRON_SCHEDULE="0 2 * * *"` - Schedule for cron job, _defaults to every day at 2:00 AM_ [syntax reference](https://en.wikipedia.org/wiki/Cron)

5. `FSBACKUP_MODE=[init|backup|restore]` -
5. `FSBACKUP_MODE=[init|backup|restore]` - `init` initializes the Restic repository at `$RESTIC_REPOSITORY` (only do this once); `backup` performs a backup; `restore` performs a restoration.

6. `LOGENTRIES_KEY` - (optional) If provided, the image will send command output to syslog with priority `user.info`.

7. `RESTIC_BACKUP_ARGS` - additional arguments to pass to 'restic backup' command

8. `RESTIC_FORGET_ARGS` - additional arguments to pass to 'restic forget --prune' command (e.g., --keep-daily 7 --keep-weekly 5 --keep-monthly 3 --keep-yearly 2)

9. `RESTIC_HOST` - hostname to record as source of backup
9. `RESTIC_HOST` - hostname to be used for the backup

10. `RESTIC_PASSWORD` - password for the Restic repository

11. `RESTIC_REPOSITORY` - Restic repository location (e.g., 's3:s3.amazonaws.com/bucketname/restic')

12. `SOURCE_PATH` - full path to the source directory to be backed up
12. `RESTIC_TAG` - tag to apply to the backup

13. `TARGET_PATH` - full path to the target directory to be restored to (usually the same as the SOURCE\_PATH)
13. `SOURCE_PATH` - full path to the source directory to be backed up

14. `TARGET_PATH` - full path to the target directory to be restored to (usually the same as the SOURCE\_PATH)

It's recommended that your S3 bucket **NOT** have versioning turned on.
Old versions of Restic's repository files are not useful.
Expand Down
12 changes: 9 additions & 3 deletions application/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
logger -p user.info "Started backup..."

start=$(date +%s)
runny $(/usr/local/bin/restic backup ${RESTIC_BACKUP_ARGS} ${SOURCE_PATH})
runny /usr/local/bin/restic backup --host ${RESTIC_HOST} --tag ${RESTIC_TAG} ${RESTIC_BACKUP_ARGS} ${SOURCE_PATH}
end=$(date +%s)

logger -p user.info "Backup completed in $(expr ${end} - ${start}) seconds."

start=$(date +%s)
runny $(/usr/local/bin/restic forget ${RESTIC_FORGET_ARGS} --prune)
runny /usr/local/bin/restic forget --host ${RESTIC_HOST} ${RESTIC_FORGET_ARGS} --prune
end=$(date +%s)

logger -p user.info "Backup pruning completed in $(expr ${end} - ${start}) seconds."

start=$(date +%s)
runny $(/usr/local/bin/restic check)
runny /usr/local/bin/restic check
end=$(date +%s)

logger -p user.info "Repository check completed in $(expr ${end} - ${start}) seconds."

start=$(date +%s)
runny /usr/local/bin/restic unlock
end=$(date +%s)

logger -p user.info "Repository unlock completed in $(expr ${end} - ${start}) seconds."

logger -p user.info "...completed backup."
2 changes: 0 additions & 2 deletions application/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env sh

hostname ${RESTIC_HOST}

if [ "${LOGENTRIES_KEY}" ]; then
sed -i /etc/rsyslog.conf -e "s/LOGENTRIESKEY/${LOGENTRIES_KEY}/"
rsyslogd
Expand Down
2 changes: 1 addition & 1 deletion application/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
logger -p user.info "Started Restic repository initialization..."

start=$(date +%s)
runny $(/usr/local/bin/restic init)
runny /usr/local/bin/restic init
end=$(date +%s)

logger -p user.info "Repository initialization completed in $(expr ${end} - ${start}) seconds."
Expand Down
10 changes: 9 additions & 1 deletion application/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
logger -p user.info "Restoring ${RESTIC_RESTORE_ID}..."

start=$(date +%s)
runny $(/usr/local/bin/restic restore ${RESTIC_RESTORE_ID} --target ${TARGET_PATH})
runny /usr/local/bin/restic restore ${RESTIC_RESTORE_ID} --host ${RESTIC_HOST} --tag ${RESTIC_TAG} --target ${TARGET_PATH}
end=$(date +%s)

logger -p user.info "Restoration completed in $(expr ${end} - ${start}) seconds."

start=$(date +%s)
runny /usr/local/bin/restic unlock
end=$(date +%s)

logger -p user.info "Repository unlock completed in $(expr ${end} - ${start}) seconds."

logger -p user.info "...completed restore."
1 change: 1 addition & 0 deletions local.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ RESTIC_FORGET_ARGS=
RESTIC_HOST=
RESTIC_PASSWORD=
RESTIC_REPOSITORY=
RESTIC_TAG=
SOURCE_PATH=
TARGET_PATH=

0 comments on commit 16ce005

Please sign in to comment.