Skip to content

Commit b198899

Browse files
committed
Update README to include rsync feature and usage examples; modify Dockerfile to add rsync as a package dependency.
1 parent 316119a commit b198899

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
## Features
1616
- 🐧 **Debian-based** - Get a lightweight experience, while still having Bash
17+
- 📂 **`rsync` included** - Easily back up or sync data from your Docker volumes over SSH
1718
- 🤝 **Key-based auth via ENV** - Grant access with the `AUTHORIZED_KEYS` environment variable
1819
- ⛔️ **Block IPs via ENV** - Block access with the `ALLOWED_IPS` environment variable
1920
- 🔒 **Unprivileged user** - All SSH connections are made as an unprivileged user
@@ -142,6 +143,41 @@ networks:
142143
database:
143144
```
144145

146+
# Working example: Backing up a Docker volume with `rsync`
147+
Because `rsync` is included in the image, you can mount any Docker volume into the SSH container and pull the data down to your local machine (or push it back up) over a secure SSH tunnel.
148+
149+
### 1. Mount the volume you want to back up
150+
Attach the volume to a path the SSH user can read. In this example we mount the `app_data` volume to `/data` inside the container as read-only:
151+
152+
```yaml
153+
services:
154+
ssh:
155+
image: serversideup/docker-ssh
156+
ports:
157+
- target: 2222
158+
published: 2222
159+
mode: host
160+
environment:
161+
AUTHORIZED_KEYS: >
162+
"ssh-ed25519 1234567890abcdefghijklmnoqrstuvwxyz user-a"
163+
ALLOWED_IPS: "AllowUsers tunnel@1.2.3.4"
164+
volumes:
165+
- app_data:/data:ro
166+
167+
volumes:
168+
app_data:
169+
external: true
170+
```
171+
172+
### 2. Pull the data down with `rsync`
173+
From your local machine, use `rsync` over SSH to copy the contents of the volume to a local directory:
174+
175+
```sh
176+
rsync -avz -e "ssh -p 12345" tunnel@myserver.test:/data/ ./app_data-backup/
177+
```
178+
179+
> ℹ️ **NOTE:** Drop the `:ro` flag on the volume mount if you also need to push data **back into** the volume.
180+
145181
## Resources
146182
- **[DockerHub](https://hub.docker.com/r/serversideup/ansible)** to browse the images.
147183
- **[Discord](https://serversideup.net/discord)** for friendly support from the community and the team.

src/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ENV ALLOWED_IPS="AllowUsers tunnel" \
1414
SSH_PORT="2222" \
1515
SSH_USER="tunnel"
1616

17-
ARG PACKAGE_DEPENDENCIES="openssh-server,iputils-ping,locales,tini" \
17+
ARG PACKAGE_DEPENDENCIES="openssh-server,iputils-ping,locales,rsync,tini" \
1818
REPOSITORY_BUILD_VERSION="dev"
1919

2020
COPY --chown=root:root --chmod=755 src/rootfs /

0 commit comments

Comments
 (0)