Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Aug 7, 2015
1 parent f2a6835 commit 945d314
Show file tree
Hide file tree
Showing 12 changed files with 899 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog

## 0.1.0
- Initial release
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
NAME = osixia/backup-manager
VERSION = 0.1.0

.PHONY: all build test tag_latest release

all: build

build:
docker build -t $(NAME):$(VERSION) --rm image

test:
env NAME=$(NAME) VERSION=$(VERSION) bats test/test.bats

tag_latest:
docker tag -f $(NAME):$(VERSION) $(NAME):latest

release: build test tag_latest
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi
docker push $(NAME)
@echo "*** Don't forget to run 'twgit release/hotfix finish' :)"
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# osixia/backup-manager

[![](https://badge.imagelayers.io/osixia/backup-manager:latest.svg)](https://imagelayers.io/?images=osixia/backup-manager:latest 'Get your own badge on imagelayers.io')

An image to execute periodicaly backup-manager.

## Quick start

# Run Backup Manager image
docker run --volume /host/data:/data-to-backup -d osixia/backup-manager

#### Backup directory and data persitance

Backups are created in the directory `/data/backup` by default that has been declared as a volume, so your backup files are saved outside the container in a data volume.

For more information about docker data volume, please refer to :

> [https://docs.docker.com/userguide/dockervolumes/](https://docs.docker.com/userguide/dockervolumes/)
## Environment Variables

Environement variables defaults are set in **image/env.yaml**. You can modify environment variable values directly in this file and rebuild the image ([see manual build](#manual-build)). You can also override those values at run time with -e argument or by setting your own env.yaml file as a docker volume to `/etc/env.yaml`. See examples below.

- **BACKUP_MANAGER_TARBALL_DIRECTORIES**: Directories to backup: paths without spaces in their name. Defaults to `/data-to-backup /data-to-backup2`.

- **BACKUP_MANAGER_REPOSITORY**: Where to store the archives. Defaults to `/data/backup`.

- **BACKUP_MANAGER_CRON_EXP**: Cron expression to schedule backup-manager execution. Defaults to `"0 4 * * *"`. Every days at 4am.

- **BACKUP_MANAGER_TTL**: Backup TTL in days. Defaults to `15`.

Upload configuration:

- **BACKUP_MANAGER_UPLOAD_METHOD**: Upload method. Defaults to `ftp`.

- **BACKUP_MANAGER_UPLOAD_HOSTS**: Upload to this ftp hosts. Defaults to `ftp.example.org`.

- **BACKUP_MANAGER_UPLOAD_FTP_USER**: Ftp user. Defaults to `ftp-user`.
- **BACKUP_MANAGER_UPLOAD_FTP_PASSWORD**: Ftp password. Defaults to `ftp-password`.
- **BACKUP_MANAGER_UPLOAD_TTL**: Backup TTL on the ftp hosts in days. Defaults to `60`.


### Set environment variables at run time :

Environment variable can be set directly by adding the -e argument in the command line, for example :

docker run -e BACKUP_MANAGER_TARBALL_DIRECTORIES="/home/billy" -d osixia/backup-manager

Or by setting your own `env.yaml` file as a docker volume to `/etc/env.yaml`

docker run -v /data/my-env.yaml:/etc/env.yaml \
-d osixia/backup-manager

## Manual build

Clone this project :

git clone https://github.com/osixia/docker-backup-manager
cd docker-backup-manager

Adapt Makefile, set your image NAME and VERSION, for example :

NAME = osixia/backup-manager
VERSION = 0.1.0

becomes :
NAME = billy-the-king/backup-manager
VERSION = 0.1.0

Build your image :

make build

Run your image :

docker run -d billy-the-king/backup-manager:0.1.0

## Tests

We use **Bats** (Bash Automated Testing System) to test this image:

> [https://github.com/sstephenson/bats](https://github.com/sstephenson/bats)
Install Bats, and in this project directory run :

make test
30 changes: 30 additions & 0 deletions image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM osixia/light-baseimage:0.1.1
MAINTAINER Bertrand Gouny <bertrand.gouny@osixia.net>

# Use baseimage's init system.
# https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/run
CMD ["/container/tool/run"]

# Use baseimage remove-service tool to remove slapd service
# including process and container start files
RUN apt-get -y update \
&& LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends \
backup-manager \
&& /container/tool/install-service-available cron \
&& rm -f /etc/backup-manager.conf

# Add service directory to /container/service
ADD service /container/service

# Use baseimage install-service script and clean all
# https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/install-service
RUN /container/tool/install-service \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Add default env variables
ADD env.yaml /etc/env.yaml

# Set backup data in a data volume
# Must match env var BACKUP_MANAGER_REPOSITORY
VOLUME ["/data/backup"]
18 changes: 18 additions & 0 deletions image/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Directories to backup: paths without spaces in their name
BACKUP_MANAGER_TARBALL_DIRECTORIES: "/data-to-backup /data-to-backup2"

# Where to store the archives
BACKUP_MANAGER_REPOSITORY: /data/backup

# Run backup-manager at 4:00am
BACKUP_MANAGER_CRON_EXP: "0 4 * * *"

# Delete backups that are over 15 days
BACKUP_MANAGER_TTL: 15

# Ftp upload config
BACKUP_MANAGER_UPLOAD_METHOD: ftp
BACKUP_MANAGER_UPLOAD_HOSTS: ftp.example.org
BACKUP_MANAGER_UPLOAD_FTP_USER: ftp-user
BACKUP_MANAGER_UPLOAD_FTP_PASSWORD: ftp-password
BACKUP_MANAGER_UPLOAD_TTL: 60 # Delete backups on the ftp that are over 60 days
Loading

0 comments on commit 945d314

Please sign in to comment.