mirror of
https://github.com/ep1cman/unifi-protect-backup.git
synced 2025-12-05 23:53:30 +00:00
Compare commits
5 Commits
v0.13.0
...
docker_use
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94d7baff01 | ||
|
|
1afa17255f | ||
|
|
e846537411 | ||
|
|
f71ee62bb4 | ||
|
|
ce85b67f99 |
50
Dockerfile
50
Dockerfile
@@ -3,22 +3,56 @@
|
||||
# $ docker build -t ghcr.io/ep1cman/unifi-protect-backup .
|
||||
FROM python:3.9-alpine
|
||||
|
||||
WORKDIR /app
|
||||
RUN apk add gcc musl-dev zlib-dev jpeg-dev rclone
|
||||
COPY dist/unifi-protect-backup-0.4.0.tar.gz sdist.tar.gz
|
||||
RUN pip install sdist.tar.gz
|
||||
# Install packages
|
||||
RUN apk add shadow gcc musl-dev zlib-dev jpeg-dev rclone
|
||||
|
||||
# Create user + directories
|
||||
RUN groupmod -g 1000 users && \
|
||||
useradd -u 911 -U -d /config -s /bin/false abc && \
|
||||
usermod -G users abc && \
|
||||
mkdir -p \
|
||||
/config \
|
||||
/defaults \
|
||||
/data
|
||||
|
||||
COPY misc/docker /
|
||||
|
||||
# Install unifi-protect-backup
|
||||
COPY dist/unifi-protect-backup-0.4.0.tar.gz /tmp/sdist.tar.gz
|
||||
RUN pip install /tmp/sdist.tar.gz && rm /tmp/sdist.tar.gz
|
||||
|
||||
# Settings
|
||||
ENV UFP_USERNAME=unifi_protect_user
|
||||
ENV UFP_PASSWORD=unifi_protect_password
|
||||
ENV UFP_ADDRESS=127.0.0.1
|
||||
ENV UFP_PORT=443
|
||||
ENV UFP_SSL_VERIFY=true
|
||||
ENV RCLONE_RETENTION=7d
|
||||
ENV RCLONE_DESTINATION=my_remote:/unifi_protect_backup
|
||||
ENV RCLONE_DESTINATION=local:/data
|
||||
ENV VERBOSITY="v"
|
||||
ENV TZ=UTC
|
||||
ENV IGNORE_CAMERAS=""
|
||||
ENV TZ=UTC
|
||||
ENV PUID=1000
|
||||
ENV PGID=1000
|
||||
|
||||
VOLUME [ "/root/.config/rclone/" ]
|
||||
VOLUME [ "/config" ]
|
||||
VOLUME [ "/data" ]
|
||||
|
||||
CMD ["sh", "-c", "unifi-protect-backup -${VERBOSITY}"]
|
||||
# Currently borken because there is no v3 release with support for changing PATH
|
||||
# Setup S6
|
||||
# ARG S6_OVERLAY_VERSION=3.0.0.2-2
|
||||
# ARG S6_OVERLAY_ARCH=x86_64
|
||||
# ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch-${S6_OVERLAY_VERSION}.tar.xz /tmp
|
||||
# RUN tar -C / -Jxpf /tmp/s6-overlay-noarch-${S6_OVERLAY_VERSION}.tar.xz
|
||||
# ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}-${S6_OVERLAY_VERSION}.tar.xz /tmp
|
||||
# RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64-${S6_OVERLAY_VERSION}.tar.xz
|
||||
# ENV PATH=/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
# set version for s6 overlay
|
||||
ARG OVERLAY_VERSION="v2.2.0.3"
|
||||
ARG OVERLAY_ARCH="amd64"
|
||||
|
||||
# add s6 overlay
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/
|
||||
RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer
|
||||
ENTRYPOINT ["/init"]
|
||||
@@ -129,12 +129,12 @@ docker run \
|
||||
-e UFP_ADDRESS='UNIFI_PROTECT_IP' \
|
||||
-e UFP_SSL_VERIFY='false' \
|
||||
-e RCLONE_DESTINATION='my_remote:/unifi_protect_backup' \
|
||||
-v '/path/to/rclone.conf':'/root/.config/rclone/rclone.conf' \
|
||||
-v '/path/to/rclone.conf':'/config/rclone.conf' \
|
||||
ghcr.io/ep1cman/unifi-protect-backup
|
||||
```
|
||||
If you do not already have a `rclone.conf` file you can create one as follows:
|
||||
```
|
||||
$ docker run -it --rm -v $PWD:/root/.config/rclone/ ghcr.io/ep1cman/unifi-protect-backup rclone config
|
||||
$ docker run -it --rm -v $PWD:/config ghcr.io/ep1cman/unifi-protect-backup rclone config
|
||||
```
|
||||
This will create a `rclone.conf` file in your current directory
|
||||
|
||||
|
||||
2
misc/docker/defaults/rclone.conf
Normal file
2
misc/docker/defaults/rclone.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
[local]
|
||||
type = local
|
||||
8
misc/docker/etc/cont-init.d/01-setup-user
Executable file
8
misc/docker/etc/cont-init.d/01-setup-user
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/with-contenv /bin/sh
|
||||
|
||||
echo "[cont-init.d] Setting up user"
|
||||
PUID=${PUID:-911}
|
||||
PGID=${PGID:-911}
|
||||
|
||||
groupmod -o -g "$PGID" abc
|
||||
usermod -o -u "$PUID" abc
|
||||
8
misc/docker/etc/cont-init.d/02-config
Executable file
8
misc/docker/etc/cont-init.d/02-config
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/with-contenv /bin/sh
|
||||
|
||||
# default config file
|
||||
[[ ! -f "/config/rclone.conf" ]] && \
|
||||
echo "[cont-init.d] Copying default config"
|
||||
cp \
|
||||
/defaults/rclone.conf \
|
||||
/config/rclone.conf
|
||||
4
misc/docker/etc/cont-init.d/03-permissions
Normal file
4
misc/docker/etc/cont-init.d/03-permissions
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/with-contenv /bin/sh
|
||||
|
||||
chown abc:abc /data
|
||||
chown -R abc:abc /config
|
||||
4
misc/docker/etc/services.d/unifi-protect-backup/run
Normal file
4
misc/docker/etc/services.d/unifi-protect-backup/run
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/with-contenv /bin/sh
|
||||
|
||||
export RCLONE_CONFIG="/config/rclone.conf"
|
||||
s6-setuidgid abc unifi-protect-backup -${VERBOSITY}
|
||||
@@ -485,7 +485,7 @@ class UnifiProtectBackup:
|
||||
Raises:
|
||||
RuntimeError: If rclone returns a non-zero exit code
|
||||
"""
|
||||
cmd = f"rclone rcat -vv {rclone_args} '{destination}'"
|
||||
cmd = f'rclone rcat -vv {rclone_args} "{destination}"'
|
||||
proc = await asyncio.create_subprocess_shell(
|
||||
cmd,
|
||||
stdin=asyncio.subprocess.PIPE,
|
||||
|
||||
Reference in New Issue
Block a user