Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restore #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM debian:jessie
FROM alpine:3.4
MAINTAINER Vitalii Vokhmin <[email protected]>

RUN apk add --no-cache curl bzip2
COPY backup.sh /bin/backup.sh
COPY restore.sh /bin/restore.sh
RUN chmod +x /bin/backup.sh /bin/restore.sh

ENV VOLUME_MOUNT_POINT '/data'
ENV ARCHIVE_NAME_PREFIX 'volume_container'
ENV FTP_PATH ''
ENV FTP_USER 'anonymous'
ENV FTP_PASSWORD ''

RUN apt-get update && apt-get install -y curl bzip2 && apt-get clean && rm -rf /var/lib/apt/lists

ADD upload_archive.sh /bin/upload_archive.sh
RUN chmod +x /bin/upload_archive.sh
CMD [ "/bin/upload_archive.sh" ]
CMD [ "/bin/backup.sh" ]
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# volume-ftp-backup
Docker image for simple volumes backup over FTP.
Docker image for simple volumes backup/restore over FTP.

# Description
Image with a simple script that archives the data from the Docker volume
Expand All @@ -9,14 +9,27 @@ Uses user provided archive name prefix + unix timestamp as suffix for the filena
I. e. `volume_container-123456789.tar.bz2`.

# Usage

## Backup
Image accepts following environment variables:
- `VOLUME_MOUNT_POINT` - path where volume is mounted. Default is `/data`
- `ARCHIVE_NAME_PREFIX` - prefix for archive file name. Default is `volume_container`
- `FTP_PATH` - full path to FTP folder. I. e. `ftp://example.com/path/to/storage/`
- `FTP_USER` - FTP username. Default is `anonymous`
- `FTP_PASSWORD` - FTP password for authentication

## Example
### Example
```bash
docker run --rm -v my_shiny_volume:/data -e ARCHIVE_NAME_PREFIX='my_shiny_backup' -e FTP_PATH='ftp://example.com/backups/shiny_folder/' -e FTP_USER='user' -e FTP_PASSWORD='secret' vit1/volume-ftp-backup
```

## Restore
- `VOLUME_MOUNT_POINT` - path where volume is mounted. Default is `/data`
- `FTP_PATH` - full path to archive. I. e. `ftp://example.com/path/to/storage/volume_container_1234.tar.bz2`
- `FTP_USER` - FTP username. Default is `anonymous`
- `FTP_PASSWORD` - FTP password for authentication

### Example
```bash
docker run --rm -v my_shiny_volume:/data -e -e FTP_PATH='ftp://example.com/backups/shiny_folder/volume_container_1234.tar.bz2' -e FTP_USER='user' -e FTP_PASSWORD='secret' vit1/volume-ftp-backup restore.sh
```
3 changes: 2 additions & 1 deletion upload_archive.sh → backup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
set -x

# Required env vars:
#
Expand Down
14 changes: 14 additions & 0 deletions restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env sh
set -e

# Required env vars:
#
# $VOLUME_MOUNT_POINT
# $FTP_PATH
# $FTP_USER
# $FTP_PASSWORD

cmd="curl $FTP_PATH --user '$FTP_USER:$FTP_PASSWORD' -o /tmp/archive.tar.bz2"
eval "$cmd"
tar -jxC / -f /tmp/archive.tar.bz2
rm /tmp/archive.tar.bz2