Skip to content
Merged
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
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ FROM alpine:3

ARG TARGETPLATFORM

VOLUME /backups

RUN apk add --no-cache libc6-compat

ADD ${TARGETPLATFORM}/git-backup /
RUN chmod +x /git-backup

VOLUME /backups
## Add the user for command execution
RUN apk add --no-cache shadow

ADD ./docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/git-backup", "-backup.path", "/backups", "-config.file", "/backups/git-backup.yml"]
ENTRYPOINT ["/docker-entrypoint.sh", "-backup.path", "/backups", "-config.file", "/backups/git-backup.yml"]
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,16 @@ First, create your [git-backup.yml file](#configuration-file) at `/path/to/your/
Then update your backups using the mounted volume.

```bash
docker run --volume /path/to/backups:/backups ghcr.io/chappio/git-backup:latest
docker run -v /path/to/backups:/backups ghcr.io/chappio/git-backup:1
```

### Parameters

You can specify several parameters when starting this container.

| **Parameter** | **Description** |
|--------------------------------|----------------------------------------------------------------------------------------|
| `-v /path/to/backups:/backups` | Mount the folder where you want to store your backups and read you configuration file. |
| `-e TZ=Europe/Amsterdam` | Set the timezone used for logging. |
| `-e PUID=0` | Set the user id of the unix user who will own the backup files in /backup. |
| `-e PGID=0` | Set the group id of the unix user's group who will own the backup files. |
22 changes: 22 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
set -eu
if [[ -z "${PUID-}" && -z "${PGID-}" ]]
then
# We are running through normal docker user changes, so nothing special to do
/git-backup "$@"
else
# We are running with an environment variable user change
PUID=${PUID:-$(id -u)}
PGID=${PGID:-$(id -g)}

# Make sure the user exists
useradd -o -u "$PUID" -U -d /backups -s /bin/false git-backup
groupmod -o -g "$PGID" git-backup

# Own the backups folder
chown git-backup:git-backup /backups

# Let's go!
echo /git-backup "$@" | su -s /bin/sh git-backup
fi