mirror of
https://github.com/ViViDboarder/docker-restic-cron.git
synced 2024-11-24 14:16:36 +00:00
Getting better
Dropping platform Dockerfiles
This commit is contained in:
parent
bcef9a9ce4
commit
7962a77e8b
@ -1,50 +0,0 @@
|
|||||||
FROM resin/rpi-raspbian:jessie
|
|
||||||
MAINTAINER ViViDboarder <vividboarder@gmail.com>
|
|
||||||
|
|
||||||
RUN [ "cross-build-start" ]
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
cron \
|
|
||||||
duplicity \
|
|
||||||
lftp \
|
|
||||||
ncftp \
|
|
||||||
openssh-client \
|
|
||||||
python-cloudfiles \
|
|
||||||
python-gdata \
|
|
||||||
python-oauthlib \
|
|
||||||
python-paramiko \
|
|
||||||
python-pexpect \
|
|
||||||
python-pip \
|
|
||||||
python-setuptools \
|
|
||||||
python-urllib3 \
|
|
||||||
rsync \
|
|
||||||
tahoe-lafs \
|
|
||||||
&& pip install -U boto b2 \
|
|
||||||
&& apt-get remove -y python-pip \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
python-swiftclient \
|
|
||||||
&& rm -rf /var/apt/lists/*
|
|
||||||
|
|
||||||
RUN [ "cross-build-end" ]
|
|
||||||
|
|
||||||
VOLUME /root/.cache/duplicity
|
|
||||||
VOLUME /backups
|
|
||||||
VOLUME /var/lock/duplicity
|
|
||||||
|
|
||||||
ENV BACKUP_DEST="file:///backups"
|
|
||||||
ENV BACKUP_NAME="backup"
|
|
||||||
ENV PATH_TO_BACKUP="/data"
|
|
||||||
ENV PASSPHRASE="Correct.Horse.Battery.Staple"
|
|
||||||
|
|
||||||
# Cron schedules
|
|
||||||
ENV CRON_SCHEDULE=""
|
|
||||||
ENV FULL_CRON_SCHEDULE=""
|
|
||||||
ENV VERIFY_CRON_SCHEDULE=""
|
|
||||||
|
|
||||||
ADD backup.sh /
|
|
||||||
ADD restore.sh /
|
|
||||||
ADD start.sh /
|
|
||||||
ADD verify.sh /
|
|
||||||
|
|
||||||
CMD [ "/start.sh" ]
|
|
@ -1,27 +0,0 @@
|
|||||||
FROM ubuntu:artful
|
|
||||||
MAINTAINER ViViDboarder <vividboarder@gmail.com>
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
cron \
|
|
||||||
restic \
|
|
||||||
&& apt-get clean \
|
|
||||||
&& rm -rf /var/apt/lists/*
|
|
||||||
|
|
||||||
VOLUME /root/.cache/restic
|
|
||||||
VOLUME /backups
|
|
||||||
|
|
||||||
ENV BACKUP_DEST="/backups"
|
|
||||||
ENV BACKUP_NAME="backup"
|
|
||||||
ENV PATH_TO_BACKUP="/data"
|
|
||||||
|
|
||||||
# Cron schedules
|
|
||||||
ENV CRON_SCHEDULE=""
|
|
||||||
ENV VERIFY_CRON_SCHEDULE=""
|
|
||||||
|
|
||||||
ADD backup.sh /
|
|
||||||
ADD restore.sh /
|
|
||||||
ADD start.sh /
|
|
||||||
ADD verify.sh /
|
|
||||||
|
|
||||||
CMD [ "/start.sh" ]
|
|
8
Makefile
8
Makefile
@ -8,18 +8,18 @@ test: test-x86
|
|||||||
|
|
||||||
.PHONY: build-x86
|
.PHONY: build-x86
|
||||||
build-x86:
|
build-x86:
|
||||||
docker build -f ./Dockerfile.ubuntu -t $(DOCKER_TAG):ubuntu .
|
docker build -f ./Dockerfile -t $(DOCKER_TAG) --platform linux .
|
||||||
|
|
||||||
.PHONY: build-arm
|
.PHONY: build-arm
|
||||||
build-arm:
|
build-arm:
|
||||||
docker build -f ./Dockerfile.raspbian -t $(DOCKER_TAG):raspbian .
|
docker build -f ./Dockerfile -t $(DOCKER_TAG) --platform arm .
|
||||||
|
|
||||||
.PHONY: build-all
|
.PHONY: build-all
|
||||||
build-all: build-x86 build-arm
|
build-all: build-x86 build-arm
|
||||||
|
|
||||||
.PHONY: test-x86
|
.PHONY: test-x86
|
||||||
test-x86: build-x86
|
test-x86: build-x86
|
||||||
cd tests && ./test.sh $(DOCKER_TAG):ubuntu
|
cd tests && ./test.sh $(DOCKER_TAG)
|
||||||
|
|
||||||
.PHONY: test-arm
|
.PHONY: test-arm
|
||||||
test-arm: build-arm
|
test-arm: build-arm
|
||||||
@ -41,7 +41,7 @@ test-s3-all: test-s3-x86 test-s3-arm
|
|||||||
|
|
||||||
.PHONY: shell-x86
|
.PHONY: shell-x86
|
||||||
shell-x86: build-x86
|
shell-x86: build-x86
|
||||||
docker run --rm -it $(DOCKER_TAG):ubuntu bash
|
docker run --rm -it $(DOCKER_TAG) bash
|
||||||
|
|
||||||
.PHONY: shell-arm
|
.PHONY: shell-arm
|
||||||
shell-arm: build-arm
|
shell-arm: build-arm
|
||||||
|
34
Readme.md
34
Readme.md
@ -8,37 +8,25 @@ Mount any directories you'd like to back up as a volume and run
|
|||||||
## Env Variables
|
## Env Variables
|
||||||
| Variable | Default | Description |
|
| Variable | Default | Description |
|
||||||
| -------- | ------- | ----------- |
|
| -------- | ------- | ----------- |
|
||||||
|AWS_ACCESS_KEY_ID| |Required for writing to S3|
|
|AWS_ACCESS_KEY_ID| |Required for writing to S3 or Minio|
|
||||||
|AWS_DEFAULT_REGION| |Required for writing to S3|
|
|AWS_SECRET_ACCESS_KEY| |Required for writing to S3 or Minio|
|
||||||
|AWS_SECRET_ACCESS_KEY| |Required for writing to S3|
|
|B2_ACCOUNT_ID| |Required for writing to B2|
|
||||||
|BACKUP_DEST|/backups|Destination to store backups (See [duplicity documenation](http://duplicity.nongnu.org/duplicity.1.html#sect7))|
|
|B2_ACCOUNT_KEY| |Required for writing to B2|
|
||||||
|BACKUP_NAME|backup|What the name for the backup should be. If using a single store for multiple backups, make sure this is unique|
|
|BACKUP_DEST|/backups|Destination to store backups (See [restic documenation](https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html))|
|
||||||
|CLEANUP_COMMAND| |An optional duplicity command to execute after backups to clean older ones out (eg. "remove-all-but-n-full 2")|
|
|CLEANUP_COMMAND| |Optional restic arguments for `forget` to execute after backups to clean older ones out (eg. "--prune --keep-last 2"). See [forget](https://restic.readthedocs.io/en/latest/060_forget.html)|
|
||||||
|CRON_SCHEDULE| |If you want to periodic incremental backups on a schedule, provide it here. By default we just backup once and exit|
|
|CRON_SCHEDULE| |If you want to periodic incremental backups on a schedule, provide it here. By default we just backup once and exit|
|
||||||
|FTP_PASSWORD| |Used to provide passwords for some backends. May not work without an attached TTY|
|
|
||||||
|FULL_CRON_SCHEDULE| |If you want to periodic full backups on a schedule, provide it here. This requires an incremental cron schedule too|
|
|FULL_CRON_SCHEDULE| |If you want to periodic full backups on a schedule, provide it here. This requires an incremental cron schedule too|
|
||||||
|GPG_KEY_ID| |The ID of the key you wish to use. See [Encryption](#encryption) section below|
|
|OPT_ARGUMENTS| |Any additional arguments to provide to the restic command|
|
||||||
|OPT_ARGUMENTS| |Any additional arguments to provide to the duplicity backup command|
|
|RESTIC_PASSWORD| |Passphrase to use for encryption|
|
||||||
|PASSPHRASE|Correct.Horse.Battery.Staple|Passphrase to use for GPG|
|
|PATH_TO_BACKUP|/data|The path to the directory you wish to backup|
|
||||||
|PATH_TO_BACKUP|/data|The path to the directory you wish to backup. If you want to backup multiple, see the [tip below](#backing-up-more-than-one-source-directory)|
|
|
||||||
|RESTORE_ON_EMPTY_START| |Set this to "true" and if the `$PATH_TO_BACKUP` is empty, it will restore the latest backup. This can be used for auto recovery from lost data|
|
|RESTORE_ON_EMPTY_START| |Set this to "true" and if the `$PATH_TO_BACKUP` is empty, it will restore the latest backup. This can be used for auto recovery from lost data|
|
||||||
|SKIP_ON_START| |Skips backup on start if set to "true"|
|
|SKIP_ON_START| |Skips backup on start if set to "true"|
|
||||||
|VERIFY_CRON_SCHEDULE| |If you want to verify your backups on a schedule, provide it here|
|
|VERIFY_CRON_SCHEDULE| |If you want to verify your backups on a schedule, provide it here|
|
||||||
|
|
||||||
## Tips
|
## Tips
|
||||||
|
|
||||||
### Missing dependencies?
|
## Hostnames
|
||||||
Please file a ticket! Duplicity supports a ton of backends and I haven't had a chance to validate that all dependencies are present in the image. If something is missing, let me know and I'll add it
|
Hostname is used for identifying what you are backing up. You may want to specify this on your container.
|
||||||
|
|
||||||
### Getting complains about no terminal for askpass?
|
|
||||||
Instead of using `FTP_PASSWORD`, add the password to the endpoint url
|
|
||||||
|
|
||||||
### Backing up more than one source directory
|
|
||||||
Duplicity only accepts one target, however you can refine that selection with `--exclude` and `--include` arguments. The below example shows how this can be used to select multiple backup sources
|
|
||||||
```
|
|
||||||
OPT_ARGUMENTS="--include /home --include /etc --exclude '**'"
|
|
||||||
PATH_TO_BACKUP="/"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Backing up from another container
|
### Backing up from another container
|
||||||
Mount all volumes from your existing container with `--volumes-from` and then back up by providing the paths to those volumes. If there are more than one volumes, you'll want to use the above tip for mulitple backup sources
|
Mount all volumes from your existing container with `--volumes-from` and then back up by providing the paths to those volumes. If there are more than one volumes, you'll want to use the above tip for mulitple backup sources
|
||||||
|
@ -5,8 +5,7 @@ restic \
|
|||||||
-r $BACKUP_DEST \
|
-r $BACKUP_DEST \
|
||||||
$OPT_ARGUMENTS \
|
$OPT_ARGUMENTS \
|
||||||
backup \
|
backup \
|
||||||
$PATH_TO_BACKUP \
|
$PATH_TO_BACKUP
|
||||||
--tag $BACKUP_NAME \
|
|
||||||
|
|
||||||
if [ -n "$CLEANUP_COMMAND" ]; then
|
if [ -n "$CLEANUP_COMMAND" ]; then
|
||||||
restic \
|
restic \
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
services:
|
services:
|
||||||
duplicity:
|
restic:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.ubuntu
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- ./my-backups:/backups
|
- ./my-backups:/backups
|
||||||
- ./my-data:/data:ro
|
- ./my-data:/data:ro
|
||||||
|
@ -3,7 +3,7 @@ services:
|
|||||||
restic:
|
restic:
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: Dockerfile.${DOCKER_BASE}
|
dockerfile: Dockerfile
|
||||||
entrypoint: "bash"
|
entrypoint: "bash"
|
||||||
command: "-c 'sleep 2 && /test.sh'"
|
command: "-c 'sleep 2 && /test.sh'"
|
||||||
hostname: itest
|
hostname: itest
|
||||||
|
Loading…
Reference in New Issue
Block a user