Skip to content

Commit

Permalink
Merge pull request #44 from BCDevOps/mongo
Browse files Browse the repository at this point in the history
Add support for Mongo
  • Loading branch information
WadeBarnes authored Mar 11, 2020
2 parents 0a4c675 + a312d3a commit a576346
Show file tree
Hide file tree
Showing 26 changed files with 2,480 additions and 1,577 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* text=auto

# Declare files that will always have LF line endings on checkout.
backup.* text eol=lf
*.sh text eol=lf
*.md text eol=lf
*.json text eol=lf
Expand Down
82 changes: 57 additions & 25 deletions README.md

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions config/backup.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
# The entries must be in one of the following forms:
# - <Hostname/>/<DatabaseName/>
# - <Hostname/>:<Port/>/<DatabaseName/>
# - <DatabaseType>=<Hostname/>/<DatabaseName/>
# - <DatabaseType>=<Hostname/>:<Port/>/<DatabaseName/>
# <DatabaseType> can be postgres or mongo
# <DatabaseType> MUST be specified when you are sharing a
# single backup.conf file between postgres and mongo
# backup containers. If you do not specify <DatabaseType>
# the listed databases are assumed to be valid for the
# backup container in which the configuration is mounted.
#
# Examples:
# - postgresql/my_database
# - postgresql:5432/my_database
# - postgres=postgresql/my_database
# - postgres=postgresql:5432/my_database
# - mongo=mongodb/my_database
# - mongo=mongodb:27017/my_database
# -----------------------------------------------------------
# Cron Scheduling:
# -----------------------------------------------------------
Expand All @@ -29,10 +39,10 @@
# -----------------------------------------------------------
# Full Example:
# -----------------------------------------------------------
# postgresql:5432/TheOrgBook_Database
# wallet-db:5432/tob_holder
# wallet-db/tob_issuer
# postgres=postgresql:5432/TheOrgBook_Database
# mongo=mender-mongodb:27017/useradm
# postgres=wallet-db/tob_issuer
#
# 0 1 * * * default ./backup.sh -s
# 0 4 * * * default ./backup.sh -s -v all
# ============================================================
# ============================================================
6 changes: 4 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ ENV TZ=PST8PDT
# Set the workdir to be root
WORKDIR /

# Load the backup script into the container (must be executable).
COPY backup.sh /
# Load the backup scripts into the container (must be executable).
COPY backup.* /

COPY webhook-template.json /

# ========================================================================================================
Expand All @@ -24,6 +25,7 @@ ARG GOCROND_VERSION=0.6.3
ADD https://github.com/$SOURCE_REPO/go-crond/releases/download/$GOCROND_VERSION/go-crond-64-linux /usr/bin/go-crond

USER root

RUN chmod ug+x /usr/bin/go-crond
# ========================================================================================================

Expand Down
42 changes: 42 additions & 0 deletions docker/Dockerfile_Mongo
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This image provides a mongo installation from which to run backups
FROM registry.access.redhat.com/rhscl/mongodb-36-rhel7

# Change timezone to PST for convenience
ENV TZ=PST8PDT

# Set the workdir to be root
WORKDIR /

# Load the backup scripts into the container (must be executable).
COPY backup.* /

COPY webhook-template.json /

# ========================================================================================================
# Install go-crond (from https://github.com/BCDevOps/go-crond)
# - Adds some additional logging enhancements on top of the upstream project;
# https://github.com/webdevops/go-crond
#
# CRON Jobs in OpenShift:
# - https://blog.danman.eu/cron-jobs-in-openshift/
# --------------------------------------------------------------------------------------------------------
ARG SOURCE_REPO=BCDevOps
ARG GOCROND_VERSION=0.6.3
ADD https://github.com/$SOURCE_REPO/go-crond/releases/download/$GOCROND_VERSION/go-crond-64-linux /usr/bin/go-crond

USER root

RUN chmod ug+x /usr/bin/go-crond
# ========================================================================================================

# ========================================================================================================
# Perform operations that require root privilages here ...
# --------------------------------------------------------------------------------------------------------
RUN echo $TZ > /etc/timezone
# ========================================================================================================

# Important - Reset to the base image's user account.
USER 26

# Set the default CMD.
CMD sh /backup.sh
Loading

0 comments on commit a576346

Please sign in to comment.