Sign inSign up

krustyhack/helicopterizer

By krustyhack

Updated almost 10 years ago

Backup to Cloud providers

Artifact
0

1.1K

krustyhack/helicopterizer repository overview

Helicopterizer

Forked from Frekele Helicopterizer. Thanks ! Forked by Nicolas Hug

Solution Open Source in Backup and Restore, for Docker Container in the Cloud Providers!

CircleCI GitHub license

Backup and Restore for Docker Container

Solution Open Source in Backup and Restore, for Docker Container in the Cloud Providers!
Usage:
docker run -d [Environment Variables] [-v|--volumes-from] frekele/helicopterizer [backup|restore] [--tarball|--sync]
Use Stable Branch for (Production)
docker run -d frekele/helicopterizer:stable
Master Branch for (Development)
docker run -d frekele/helicopterizer:latest
# or
docker run -d frekele/helicopterizer
Specific Tag Version
  docker run -d frekele/helicopterizer:v0.2.1
Cloud Storage Provider Supported:
ProviderVariable ValueSupported
Amazon Simple Storage Service (S3)AWSyes
Microsoft Azure StorageAZUREno - Planned for the future
Google Cloud StorageGOOGLEno - Planned for the future
Rackspace StorageRACKSPACEno - Planned for the future
IBM SoftLayer StorageSOFTLAYERno - Planned for the future
Oracle Cloud StorageORACLEno - Planned for the future
OpenStack Swift Storage (Open source)OPENSTACKno - Planned for the future
Minio Storage (Open source)MINIOno - Planned for the future
Environment Variables:
Variable NameDefaultActionRequiredOptionDescription
STORAGE_PROVIDERnullbackup, restoreyestarball, syncProvider name (AWS, AZURE, GOOGLE ...)
DATA_PATH/data/backup, restorenotarball, syncData path : /data/(your files)
DATA_PATH_EXCLUDEnullbackupnotarballExclude file from data path (comma-separated)
CRON_SCHEDULEnullbackup, restorenotarball, syncCron Job Scheduler, Eg: '*/15 * * * *' run every 15 minutes
BACKUP_PREFIXnullbackup, restorenotarballDefault name schema: $(BACKUP_PREFIX)$(BACKUP_VERSION).tar.gz
BACKUP_NAMEnullbackup, restorenotarballIf defined the name shcema is: $(BACKUP_NAME).tar.gz
GZIP_COMPRESSIONtruebackup, restorenotarballBoolean to indicate the compression of the file .tar to .tar.gz
CLEAN_DATA_BEFORE_RESTOREfalserestorenotarball, syncClear the data directory before the restore
BACKUP_VERSIONnullrestoreyestarballBackup version using: $(BACKUP_VERSION).tar.gz
Environment Variables for AWS S3:
Variable NameDefaultActionRequiredOptionDescription
AWS_ACCESS_KEY_IDnullbackup, restoreyestarball, syncAWS access key. Eg: AKRJPMI3QYCARJCRF4VF
AWS_SECRET_ACCESS_KEYnullbackup, restoreyestarball, syncAWS secret key. Eg: VCsrO7aVulGuiUdXbS31jtQA4iRTVgi4scftJAJr
AWS_S3_BUCKET_NAMEnullbackup, restoreyestarball, syncS3 bucket name. Eg: s3://my-bucket-backup/
AWS_S3_BUCKET_CREATEfalsebackupnotarball, syncBoolean to indicate if we create the bucket (if not exists)
AWS_S3_PATH/backup, restorenotarball, syncRelative path for bucket S3. Eg: (AWS_S3_BUCKET_NAME)/jenkins/
AWS_DEFAULT_REGIONus-east-1backup, restorenotarball, syncDefault region bucket. Eg: (sa-east-1)
AWS_S3_OPTIONSnullbackup, restorenotarball, syncAWS S3 options parameters. See in AWS CLI S3
AWS S3 Regions:
Region NameDescription the Region
us-east-1US East (Virginia)
us-west-1US West (N. California)
us-west-2US West (Oregon)
eu-west-1EU West (Ireland)
eu-central-1EU Central (Frankfurt)
ap-northeast-1Asia Pacific (Tokyo)
ap-northeast-2Asia Pacific (Seoul)
ap-southeast-1Asia Pacific (Singapore)
ap-southeast-2Asia Pacific (Sydney)
sa-east-1South America (Sao Paulo)
us-gov-west-1US GovCloud West (Oregon)
Usage Examples:

Run Backup with tarball:

docker run --rm \
-e STORAGE_PROVIDER=AWS \
-e AWS_ACCESS_KEY_ID=XXXXXXXXXXXXX \
-e AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
-e AWS_S3_BUCKET_NAME=s3://my-bucket-backup/ \
-v /some/dir/jenkins-data:/data:ro \
helicopterizer backup --tarball

Run Backup with sync filesystem:

docker run --rm \
-e STORAGE_PROVIDER=AWS \
-e AWS_ACCESS_KEY_ID=XXXXXXXXXXXXX \
-e AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
-e AWS_S3_BUCKET_NAME=s3://my-bucket-backup/ \
-v /some/dir/jenkins-data:/data:ro \
helicopterizer backup --sync

Use ':ro' to mount the volumes in read-only mode.

Run Restore with tarball:

docker run --rm \
-e STORAGE_PROVIDER=AWS \
-e AWS_ACCESS_KEY_ID=XXXXXXXXXXXXX \
-e AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
-e AWS_S3_BUCKET_NAME=s3://my-bucket-backup/ \
-e BACKUP_VERSION='2016-05-04T01:34:20Z' \
-v /some/dir/jenkins-data:/data:rw \
helicopterizer restore --tarball

Run Restore with sync filesystem:

docker run --rm \
-e STORAGE_PROVIDER=AWS \
-e AWS_ACCESS_KEY_ID=XXXXXXXXXXXXX \
-e AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
-e AWS_S3_BUCKET_NAME=s3://my-bucket-backup/ \
-e BACKUP_VERSION='2016-05-04T01:34:20Z' \
-v /some/dir/jenkins-data:/data:rw \
helicopterizer restore  --sync

Use ':rw' to mount the volumes in read-write mode.

Run [Backup|Restore] with environment file:

touch ~/helicopterizer.conf
##################################
# Set Your Environment Variables:
##################################
STORAGE_PROVIDER=AWS
BACKUP_NAME=my-backup-name
DATA_PATH=/data/
GZIP_COMPRESSION=true
CLEAN_DATA_BEFORE_RESTORE=false
BACKUP_VERSION=date-time-z
AWS_ACCESS_KEY_ID=XXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
AWS_S3_BUCKET_NAME=s3://my-bucket-backup/
AWS_S3_PATH=/
AWS_DEFAULT_REGION=us-east-1
AWS_S3_OPTIONS=
##################################
.
docker run --rm \
--env-file ~/helicopterizer.conf \
-v /some/dir/jenkins-data:/data \
helicopterizer [backup|restore] [--tarball|--sync]

Run [Backup|Restore] with data volume container:

docker run --rm \
........
-e DATA_PATH=/var/jenkins_home/ \
--volumes-from jenkins-data \
helicopterizer [backup|restore] [--tarball|--sync]

Run [Backup|Restore] with Cron Job Scheduler (System Timezone is UTC):

docker run -d \
........
-e CRON_SCHEDULE='30 4 * * *' \
helicopterizer [backup|restore] [--tarball|--sync]

#####################################################
######### Examples Cron Job Scheduler Usage #########
############## System Timezone is UTC ###############
#####################################################
- CRON_SCHEDULE='30 4 * * *' - Runs every day at 04:30;
- CRON_SCHEDULE='*/15 * * * *' - Runs every 15 Minutes;
- CRON_SCHEDULE='0 */5 * * *' - Runs every 5 Hours;
- CRON_SCHEDULE='0 */12 * * *' - Runs every 12 Hours;
- CRON_SCHEDULE='0 */32 * * *' - Runs every 32 Hours;
- CRON_SCHEDULE='0 0 */2 * *' - Runs every 2 Days;
- CRON_SCHEDULE='0 0 */7 * *' - Runs every 7 Days;
- CRON_SCHEDULE='0 0 0 */2 *' - Runs every 2 Months;
- CRON_SCHEDULE='@monthly' - Run once a Month, the same as: '0 0 1 * *';
- CRON_SCHEDULE='@weekly' - Run once a Week, the same as: '0 0 * * 0';
- CRON_SCHEDULE='@daily' - Run once a Day, the same as: '0 0 * * *';
- CRON_SCHEDULE='@midnight' - Run once a Day, the same as: '0 0 * * *' and @daily;
- CRON_SCHEDULE='@hourly' - Run once a Hour, the same as: '0 * * * *';

More info to usage: Cron Wiki.

Run [Backup|Restore] with prefix name $(BACKUP_NAME)-$(BACKUP_VERSION).tar.gz:

docker run --rm \
........
-e BACKUP_NAME=my-backup-name \
helicopterizer [backup|restore] --tarball

Run [Backup|Restore] without gzip compression:

docker run --rm \
........
-e GZIP_COMPRESSION=false \
helicopterizer [backup|restore] --tarball

Run [Backup|Restore] with bucket creation (if NoSuchBucket):

docker run --rm \
........
-e AWS_S3_BUCKET_CREATE=true \
helicopterizer [backup|restore] --tarball

Run With clean the date before the restore:

[Be careful here, you will lose all your data inside DATA_PATH directory].

docker run --rm \
........
-e CLEAN_DATA_BEFORE_RESTORE=true \
helicopterizer restore [--tarball|--sync]

Run [Backup|Restore] with other data path:

docker run --rm \
........
-e DATA_PATH=/var/jenkins_home/ \
-v /some/dir/jenkins-data:/var/jenkins_home \
helicopterizer [backup|restore] [--tarball|--sync]

Run [Backup] with other data path & exclude jenkins workspace:

docker run --rm \
........
-e DATA_PATH=/var/jenkins_home/ \
-e DATA_PATH_EXCLUDE=workspace \
-v /some/dir/jenkins-data:/var/jenkins_home \
helicopterizer [backup|restore] [--tarball|--sync]

Run [Backup|Restore] with other AWS Region:

docker run --rm \
........
-e AWS_DEFAULT_REGION=sa-east-1 \
helicopterizer [backup|restore] [--tarball|--sync]

Run [Backup|Restore] with subdirectories in AWS S3:

docker run --rm \
........
-e AWS_S3_PATH=/project-alpha/nexus/ \
helicopterizer [backup|restore] [--tarball|--sync]

Run [Backup|Restore] with Options AWS CLI S3:

docker run --rm \
........
-e AWS_S3_OPTIONS='--delete' \
helicopterizer [backup|restore] [--tarball|--sync]
Working with Persistent Data:

There are two general approaches to handling persistent storage requirements with Docker. See Managing Data in Containers for additional information.

Data volume container

Use a data volume container. Since data volumes are persistent until no containers use them, a container can created specifically for this purpose.

Example with Jenkins:

docker run -d --name jenkins-data jenkinsci/jenkins:2.0 echo "data-only container for Jenkins"
docker run -d -p 8080:8080 -p 50000:50000 --name jenkins --volumes-from jenkins-data jenkinsci/jenkins:2.0

Example with Nexus:

docker run -d --name nexus-data sonatype/nexus3 echo "data-only container for Nexus"
docker run -d -p 8081:8081 --name nexus --volumes-from nexus-data sonatype/nexus3
Data volume

Mount a host directory as the volume. This is not portable, as it relies on the directory existing with correct permissions on the host. However it can be useful in certain situations where this volume needs to be assigned to certain specific underlying storage.

Example with Jenkins:

mkdir /some/dir/jenkins-data && chown -R 1000:1000 /some/dir/jenkins-data
docker run -d -p 8080:8080 -p 50000:50000 --name jenkins -v /some/dir/jenkins-data:/var/jenkins_home jenkinsci/jenkins

# or

docker volume create --name jenkins-data
docker run -d -p 8080:8080 -p 50000:50000 --name jenkins -v jenkins-data:/var/jenkins_home jenkinsci/jenkins

Example with Nexus:

mkdir /some/dir/nexus-data && chown -R 200 /some/dir/nexus-data
docker run -d -p 8081:8081 --name nexus -v /some/dir/nexus-data:/nexus-data sonatype/nexus3

# or

docker volume create --name nexus-data
docker run -d -p 8081:8081 --name nexus -v nexus-data:/nexus-data sonatype/nexus3
Building:

Build with the usual

docker build -t helicopterizer .

Tests are written using bats under the tests dir

bats tests
License:

Helicopterizer is licensed under the MIT License. The terms of the license are as follows:

The MIT License (MIT)

Copyright (c) 2016 Leandro Kersting de Freitas

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.

Tag summary

Content type

Unrecognized

Digest

Size

48.7 MB

Last updated

almost 10 years ago

docker pull krustyhack/helicopterizer