Skip to content
This repository has been archived by the owner on Jan 18, 2019. It is now read-only.

Commit

Permalink
Migration to alpine solves #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Bleul committed Oct 5, 2016
1 parent a53f7d1 commit a843cd0
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 95 deletions.
21 changes: 13 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
FROM blacklabelops/centos:7.2.1511
FROM blacklabelops/alpine
MAINTAINER Steffen Bleul <[email protected]>

# rsnapshot version (e.g. 1.4.2-r0)
ARG RSNAPSHOT_VERSION=latest

# install rsnapshot
COPY configuration/rsnapshot.conf /etc/rsnapshot.conf
COPY imagescripts/docker-entrypoint.sh /usr/bin/rsnapshot.d/docker-entrypoint.sh
COPY imagescripts/rsnapshot.sh /usr/bin/rsnapshot.d/rsnapshot.sh
COPY configuration/rsnapshot.conf.default /etc/rsnapshot.conf
COPY imagescripts /usr/bin/rsnapshot.d

RUN yum install -y epel-release && \
yum install -y rsnapshot-1.3.1 && \
yum clean all && rm -rf /var/cache/yum/* && \
RUN apk upgrade --update && \
if [ "${RSNAPSHOT_VERSION}" = "latest" ]; \
then apk add rsnapshot ; \
else apk add "rsnapshot=${RSNAPSHOT_VERSION}" ; \
fi && \
mkdir -p /usr/bin/rsnapshot.d && \
cp /etc/rsnapshot.conf /usr/bin/rsnapshot.d/rsnapshot.conf && \
chmod ug+x /usr/bin/rsnapshot.d/*.sh
chmod ug+x /usr/bin/rsnapshot.d/*.sh && \
rm -rf /var/cache/apk/* && rm -rf /tmp/*

ENV BACKUP_INTERVAL= \
BACKUP_DIRECTORIES= \
Expand Down
32 changes: 0 additions & 32 deletions DockerfileAlpine

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
# rsnapshot.conf - rsnapshot configuration file #
#################################################
# #
# PLEASE BE AWARE OF THE FOLLOWING RULES: #
# PLEASE BE AWARE OF THE FOLLOWING RULE: #
# #
# This file requires tabs between elements #
# #
# Directories require a trailing slash: #
# right: /home/ #
# wrong: /home #
# #
#################################################

#######################
Expand Down Expand Up @@ -41,11 +37,11 @@ snapshot_root /snapshots/
#
# See the README file or the man page for more details.
#
cmd_cp /usr/bin/cp
#cmd_cp /bin/cp

# uncomment this to use the rm program instead of the built-in perl routine.
#
cmd_rm /usr/bin/rm
cmd_rm /bin/rm

# rsync must be enabled for anything to work. This is the only command that
# must be enabled.
Expand All @@ -58,13 +54,13 @@ cmd_rsync /usr/bin/rsync

# Comment this out to disable syslog support.
#
# cmd_logger /usr/bin/logger
#cmd_logger /usr/bin/logger

# Uncomment this to specify the path to "du" for disk usage checks.
# If you have an older version of "du", you may also want to check the
# "du_args" parameter below.
#
cmd_du /usr/bin/du
#cmd_du /usr/bin/du

# Uncomment this to specify the path to rsnapshot-diff.
#
Expand All @@ -80,16 +76,24 @@ cmd_du /usr/bin/du
#
#cmd_postexec /path/to/postexec/script

# Paths to lvcreate, lvremove, mount and umount commands, for use with
# Linux LVMs.
#
#linux_lvm_cmd_lvcreate /path/to/lvcreate
#linux_lvm_cmd_lvremove /path/to/lvremove
#linux_lvm_cmd_mount /bin/mount
#linux_lvm_cmd_umount /bin/umount

#########################################
# BACKUP INTERVALS #
# BACKUP LEVELS / INTERVALS #
# Must be unique and in ascending order #
# i.e. hourly, daily, weekly, etc. #
# e.g. alpha, beta, gamma, etc. #
#########################################

#interval hourly 6
#interval daily 7
#interval weekly 4
#interval monthly 1
#retain alpha 6
#retain beta 7
#retain gamma 4
#retain delta 3

############################################
# GLOBAL OPTIONS #
Expand All @@ -113,14 +117,20 @@ loglevel 3
# If you enable this, data will be written to the file you specify. The
# amount of data written is controlled by the "loglevel" parameter.
#
# logfile /var/log/rsnapshot.log
#logfile /var/log/rsnapshot

# If enabled, rsnapshot will write a lockfile to prevent two instances
# from running simultaneously (and messing up the snapshot_root).
# If you enable this, make sure the lockfile directory is not world
# writable. Otherwise anyone can prevent the program from running.
#
lockfile /usr/bin/rsnapshot.d/rsnapshot.pid
lockfile /var/run/rsnapshot.pid

# By default, rsnapshot check lockfile, check if PID is running
# and if not, consider lockfile as stale, then start
# Enabling this stop rsnapshot if PID in lockfile is not running
#
#stop_on_stale_lockfile 0

# Default rsync args. All rsync commands have at least these options set.
#
Expand Down Expand Up @@ -160,15 +170,15 @@ lockfile /usr/bin/rsnapshot.d/rsnapshot.pid
#include_file /path/to/include/file
#exclude_file /path/to/exclude/file

# If your version of rsync supports --link-dest, consider enable this.
# If your version of rsync supports --link-dest, consider enabling this.
# This is the best way to support special files (FIFOs, etc) cross-platform.
# The default is 0 (off).
#
#link_dest 0

# When sync_first is enabled, it changes the default behaviour of rsnapshot.
# Normally, when rsnapshot is called with its lowest interval
# (i.e.: "rsnapshot hourly"), it will sync files AND rotate the lowest
# (i.e.: "rsnapshot alpha"), it will sync files AND rotate the lowest
# intervals. With sync_first enabled, "rsnapshot sync" handles the file sync,
# and all interval calls simply rotate files. See the man page for more
# details. The default is 0 (off).
Expand All @@ -182,12 +192,32 @@ lockfile /usr/bin/rsnapshot.d/rsnapshot.pid
#use_lazy_deletes 0

# Number of rsync re-tries. If you experience any network problems or
# network card issues that tend to cause ssh to crap-out with
# "Corrupted MAC on input" errors, for example, set this to a non-zero
# value to have the rsync operation re-tried
# network card issues that tend to cause ssh to fail with errors like
# "Corrupted MAC on input", for example, set this to a non-zero value
# to have the rsync operation re-tried.
#
#rsync_numtries 0

# LVM parameters. Used to backup with creating lvm snapshot before backup
# and removing it after. This should ensure consistency of data in some special
# cases
#
# LVM snapshot(s) size (lvcreate --size option).
#
#linux_lvm_snapshotsize 100M

# Name to be used when creating the LVM logical volume snapshot(s).
#
#linux_lvm_snapshotname rsnapshot

# Path to the LVM Volume Groups.
#
#linux_lvm_vgpath /dev

# Mount point to use to temporarily mount the snapshot(s).
#
#linux_lvm_mountpath /path/to/mount/lvm/snapshot/during/backup

###############################
### BACKUP POINTS / SCRIPTS ###
###############################
Expand All @@ -201,14 +231,16 @@ lockfile /usr/bin/rsnapshot.d/rsnapshot.pid
#backup /home/foo/My Documents/ localhost/
#backup /foo/bar/ localhost/ one_fs=1, rsync_short_args=-urltvpog
#backup_script /usr/local/bin/backup_pgsql.sh localhost/postgres/
# You must set linux_lvm_* parameters below before using lvm snapshots
#backup lvm://vg0/xen-home/ lvm-vg0/xen-home/

# EXAMPLE.COM
#backup_script /bin/date "+ backup of example.com started at %c" unused1
#backup_exec /bin/date "+ backup of example.com started at %c"
#backup [email protected]:/home/ example.com/ +rsync_long_args=--bwlimit=16,exclude=core
#backup [email protected]:/etc/ example.com/ exclude=mtab,exclude=core
#backup_script ssh [email protected] "mysqldump -A > /var/db/dump/mysql.sql" unused2
#backup_exec ssh [email protected] "mysqldump -A > /var/db/dump/mysql.sql"
#backup [email protected]:/var/db/dump/ example.com/
#backup_script /bin/date "+ backup of example.com ended at %c" unused9
#backup_exec /bin/date "+ backup of example.com ended at %c"

# CVS.SOURCEFORGE.NET
#backup_script /usr/local/bin/backup_rsnapshot_cvsroot.sh rsnapshot.cvs.sourceforge.net/
Expand Down
8 changes: 4 additions & 4 deletions imagescripts/rsnapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ if [ -n "${RSNAPSHOT_HOURLY_TIMES}" ]; then
hourly_times=$RSNAPSHOT_HOURLY_TIMES
fi

echo -e interval'\t'hourly'\t'$hourly_times >> /etc/rsnapshot.conf
echo -e retain'\t'hourly'\t'$hourly_times >> /etc/rsnapshot.conf

daily_times="7"

if [ -n "${RSNAPSHOT_DAILY_TIMES}" ]; then
daily_times=$RSNAPSHOT_DAILY_TIMES
fi

echo -e interval'\t'daily'\t'$daily_times >> /etc/rsnapshot.conf
echo -e retain'\t'daily'\t'$daily_times >> /etc/rsnapshot.conf

weekly_times="4"

if [ -n "${RSNAPSHOT_WEEKLY_TIMES}" ]; then
weekly_times=$RSNAPSHOT_WEEKLY_TIMES
fi

echo -e interval'\t'weekly'\t'$weekly_times >> /etc/rsnapshot.conf
echo -e retain'\t'weekly'\t'$weekly_times >> /etc/rsnapshot.conf

monthly_times="12"

if [ -n "${RSNAPSHOT_MONTHLY_TIMES}" ]; then
monthly_times=$RSNAPSHOT_MONTHLY_TIMES
fi

echo -e interval'\t'monthly'\t'$monthly_times >> /etc/rsnapshot.conf
echo -e retain'\t'monthly'\t'$monthly_times >> /etc/rsnapshot.conf

syslogger_conf_tag=""

Expand Down
60 changes: 39 additions & 21 deletions rsnapshot-cron/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
FROM blacklabelops/rsnapshot:alpine
FROM blacklabelops/rsnapshot
MAINTAINER Steffen Bleul <[email protected]>

#Permissions, set the linux user id and group id
ARG CONTAINER_UID=1000
ARG CONTAINER_GID=1000
# build parameters
ARG JOBBER_VERSION=latest

# install Jobber
ENV JOBBER_HOME=/opt/jobber
ENV JOBBER_LIB=$JOBBER_HOME/lib
ENV GOPATH=$JOBBER_LIB

RUN export CONTAINER_USER=jenkins && \
export CONTAINER_GROUP=jenkins && \
# Add user
addgroup -g $CONTAINER_GID jobber_client && \
adduser -u $CONTAINER_UID -G jobber_client -s /bin/bash -S jobber_client && \
# Instll Jobber
RUN export JOBBER_HOME=/tmp/jobber && \
export JOBBER_LIB=$JOBBER_HOME/lib && \
export GOPATH=$JOBBER_LIB && \
export CONTAINER_UID=1000 && \
export CONTAINER_GID=1000 && \
export CONTAINER_USER=jobber_client && \
export CONTAINER_GROUP=jobber_client && \
# Install tools
apk add --update \
go \
make \
git && \
git \
curl \
wget \
make && \
mkdir -p $JOBBER_HOME && \
mkdir -p $JOBBER_LIB && \
# Install Jobber
addgroup -g $CONTAINER_GID jobber_client && \
adduser -u $CONTAINER_UID -G jobber_client -s /bin/bash -S jobber_client && \
cd $JOBBER_LIB && \
go get github.com/dshearer/jobber && \
make -C src/github.com/dshearer/jobber build DESTDIR=$JOBBER_HOME && \
if [ "${JOBBER_VERSION}" != "latest" ]; \
then \
# wget --directory-prefix=/tmp https://github.com/dshearer/jobber/releases/download/v1.1/jobber-${JOBBER_VERSION}-r0.x86_64.apk && \
# apk add --allow-untrusted /tmp/jobber-${JOBBER_VERSION}-r0.x86_64.apk ; \
cd src/github.com/dshearer/jobber && \
git checkout tags/${JOBBER_VERSION} && \
cd $JOBBER_LIB ; \
fi && \
make -C src/github.com/dshearer/jobber install DESTDIR=$JOBBER_HOME && \
cp $JOBBER_LIB/bin/* /usr/bin && \
# Install Tini Zombie Reaper And Signal Forwarder
export TINI_VERSION=0.9.0 && \
export TINI_SHA=fa23d1e20732501c3bb8eeeca423c89ac80ed452 && \
curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static -o /bin/tini && \
chmod +x /bin/tini && \
# Cleanup
apk del \
go \
make \
git && \
rm -rf /var/cache/apk/* && rm -rf /tmp/*
git \
curl \
wget \
make && \
rm -rf /var/cache/apk/* && rm -rf /tmp/* && rm -rf /var/log/*

ENV PATH=$PATH:/opt/jobber/lib/bin \
CRON_HOURLY= \
Expand Down
6 changes: 3 additions & 3 deletions rsnapshot-cron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ $ docker run -d \
--name backupdemon \
-v $(pwd)/snapshots/:/snapshots \
-e "BACKUP_DIRECTORIES=/jenkins/ jenkins_jenkins_1/" \
-e "CRON_HOURLY=0 20 1 * * *" \
-e "CRON_HOURLY=0 20 * * * *" \
-e "CRON_DAILY=0 0 2 1 * *" \
-e "CRON_WEEKLY=0 0 1 * * Mon" \
-e "CRON_WEEKLY=0 0 1 * * 1" \
-e "CRON_MONTHLY=0 0 3 20 * *" \
blacklabelops/rsnapshotd
~~~~
Expand Down Expand Up @@ -117,7 +117,7 @@ $ docker run -d \
-v $(pwd)/snapshots/:/snapshots \
-e "LOG_FILE=/rsnapshotlogs/rsnapshotd.log" \
-e "BACKUP_DIRECTORIES=/jenkins/ jenkins_jenkins_1/" \
-e "CRON_HOURLY=0 * * * * *" \
-e "CRON_HOURLY=0 15 * * * *" \
blacklabelops/rsnapshotd
~~~~

Expand Down
4 changes: 2 additions & 2 deletions rsnapshot-cron/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ "$1" = 'rsnapshotd' ]; then

source /usr/bin/rsnapshot.d/rsnapshot.sh

cron_rsnapshot_hourly="0 20 */4 * * *"
cron_rsnapshot_hourly="0 20 * * * *"

if [ -n "${CRON_HOURLY}" ]; then
cron_rsnapshot_hourly=${CRON_HOURLY}
Expand Down Expand Up @@ -79,7 +79,7 @@ _EOF_

# ----- Jobber Cron Start ------

/opt/jobber/lib/bin/jobberd
exec jobberd
fi

exec "$@"
6 changes: 6 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -x

#------------------
# CONTAINER VARIABLES
#------------------
export RSNAPSHOT_VERSION=1.4.2-r0

0 comments on commit a843cd0

Please sign in to comment.