Skip to content
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:18.04

RUN apt-get update \
&& apt-get install -y --no-install-recommends curl cron ca-certificates openssh-client iputils-ping unzip \
&& apt-get install -y --no-install-recommends curl cron ca-certificates ncftp openssh-client iputils-ping unzip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Install awscliv2 https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Docker image for performing simple backups of Docker volumes. Main features:

- Mount volumes into the container, and they'll get backed up
- Use full `cron` expressions for scheduling the backups
- Backs up to local disk, to remote host available via `scp`, to [AWS S3](https://aws.amazon.com/s3/), or to all of them
- Backs up to local disk, to remote host available via `scp` or `ftp`, to [AWS S3](https://aws.amazon.com/s3/), or to all of them
- Allows triggering a backup manually if needed
- Optionally stops containers for the duration of the backup, and starts them again afterward, to ensure consistent backups
- Optionally `docker exec`s commands before/after backing up a container, to allow easy integration with database backup tools, for example
Expand Down Expand Up @@ -248,6 +248,11 @@ Variable | Default | Notes
`SCP_DIRECTORY` | | Directory on `SCP_HOST` where backup file is stored.
`PRE_SCP_COMMAND` | | Commands that is executed on `SCP_HOST` before the backup is transferred.
`POST_SCP_COMMAND` | | Commands that is executed on `SCP_HOST` after the backup has been transferred.
`FTP_HOST` | | When provided, the resulting backup file will be uploaded by means of `ftp` to the host stated.
`FTP_PORT` | 21 | Port, on which the host stated above is listening.
`FTP_USER` | | User name to log into `FTP_HOST`.
`FTP_PASS` | | Password to log into `FTP_HOST`.
`FTP_DIRECTORY` | | Directory on `FTP_HOST` where backup file is stored.
`GPG_PASSPHRASE` | | When provided, the backup will be encrypted with gpg using this `passphrase`.
`INFLUXDB_URL` | | When provided, backup metrics will be sent to an InfluxDB instance at this URL, e.g. `https://influxdb.example.com`.
`INFLUXDB_DB` | | Required when using `INFLUXDB_URL`; e.g. `my_database`.
Expand Down
7 changes: 7 additions & 0 deletions src/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ if [ ! -z "$AWS_GLACIER_VAULT_NAME" ]; then
TIME_UPLOADED="$(date +%s.%N)"
fi

if [ ! -z "$FTP_HOST" ]; then
info "Uploading backup by means of FTP"
echo "Will upload to $FTP_HOST:$FTP_DIRECTORY"
eval ncftpput -V -u $FTP_USER -p $FTP_PASS -P $FTP_PORT $FTP_HOST $FTP_DIRECTORY $BACKUP_FILENAME
echo "Upload finished"
fi

if [ ! -z "$SCP_HOST" ]; then
info "Uploading backup by means of SCP"
SSH_CONFIG="-o StrictHostKeyChecking=no -i /ssh/id_rsa"
Expand Down
5 changes: 5 additions & 0 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ SCP_USER="${SCP_USER:-}"
SCP_DIRECTORY="${SCP_DIRECTORY:-}"
PRE_SCP_COMMAND="${PRE_SCP_COMMAND:-}"
POST_SCP_COMMAND="${POST_SCP_COMMAND:-}"
FTP_HOST="${FTP_HOST:-}"
FTP_PORT="${FTP_PORT:-21}"
FTP_USER="${FTP_USER:-}"
FTP_PASS="${FTP_PASS:-}"
FTP_DIRECTORY="${FTP_DIRECTORY:-}"
BACKUP_FILENAME=${BACKUP_FILENAME:-"backup-%Y-%m-%dT%H-%M-%S.tar.gz"}
BACKUP_ARCHIVE="${BACKUP_ARCHIVE:-/archive}"
BACKUP_UID=${BACKUP_UID:-0}
Expand Down
22 changes: 22 additions & 0 deletions test/backing-up-via-ftp/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

version: "3"

services:

dashboard:
image: grafana/grafana:7.4.5
volumes:
- grafana-data:/var/lib/grafana # This is where Grafana keeps its data

backup:
build: ../..
environment:
FTP_HOST: 192.168.0.42 # Remote host IP address
FTP_USER: pi # Remote host user to log in
FTP_PASS: supersecret # Remote host password to log in
FTP_DIRECTORY: /home/pi/backups # Remote host directory
volumes:
- grafana-data:/backup/grafana-data:ro # Mount the Grafana data volume (as read-only)

volumes:
grafana-data: