Compare commits

...

9 Commits

Author SHA1 Message Date
Sebastian Goscik
76db42da0d Change rclone config command to use this container instead of a separate rclone container 2022-08-21 19:41:37 +01:00
Sebastian Goscik
34f27c9cdc Added rclone debugging instructions 2022-08-21 19:41:13 +01:00
Sebastian Goscik
760cb56f63 Fixed rclone.conf path in back to cloud example 2022-08-21 19:30:31 +01:00
Sebastian Goscik
0783dc58d5 Update CI flows to build arm64 containers 2022-08-20 23:50:07 +01:00
Sebastian Goscik
5ae43f08af Bump version: 0.7.2 → 0.7.3 2022-07-31 11:35:25 +01:00
Sebastian Goscik
0a36102eed Fixed dockerfile for pyunifiprotect 4.0.0
As of pyunifiprotect 4.0.0, a rust based library is needed.
In order for this to install correctly, cargo is needed, and alpine
needed to be bumped to 3.16.
2022-07-31 11:24:30 +01:00
Sebastian Goscik
92be1cea5d Bump pyunifiprotect 2022-07-31 01:48:04 +01:00
Sebastian Goscik
1813bc0176 Bump version: 0.7.1 → 0.7.2 2022-07-17 20:04:03 +01:00
Sebastian Goscik
9451fb4235 Bump pyunifiprotect -> v3.9.2 2022-07-16 23:37:36 +01:00
10 changed files with 99 additions and 124 deletions

View File

@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.8.0
current_version = 0.7.3
commit = True
tag = True

View File

@@ -2,16 +2,13 @@
name: dev workflow
env:
IMAGE_NAME: ${{ github.repository }}
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master, main, dev ]
branches: [ dev ]
pull_request:
branches: [ master, main, dev ]
branches: [ dev ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
@@ -56,9 +53,6 @@ jobs:
name: Create dev container
runs-on: ubuntu-20.04
if: github.event_name != 'pull_request'
strategy:
matrix:
python-versions: [3.9]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
@@ -67,7 +61,7 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-versions }}
python-version: 3.9
- name: Install dependencies
run: |
@@ -78,20 +72,23 @@ jobs:
run: >-
poetry build
- name: build container
id: docker_build
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: log in to container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: push container image
run: |
IMAGE_ID=ghcr.io/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:dev
docker push $IMAGE_ID:dev
- name: Build and push dev
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:dev

View File

@@ -1,50 +0,0 @@
# This is a basic workflow to help you get started with Actions
name: stage & preview workflow
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master, main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
publish_dev_build:
runs-on: ubuntu-latest
strategy:
matrix:
python-versions: [ 3.9 ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-versions }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry tox tox-gh-actions
- name: test with tox
run:
tox
- name: Build wheels and source tarball
run: |
poetry version $(poetry version --short)-dev.$GITHUB_RUN_NUMBER
poetry version --short
poetry build
- name: publish to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN}}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

View File

@@ -12,9 +12,6 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
IMAGE_NAME: ${{ github.repository }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "release"
@@ -22,10 +19,6 @@ jobs:
name: Create Release
runs-on: ubuntu-20.04
strategy:
matrix:
python-versions: [3.9]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Get version from tag
@@ -46,7 +39,7 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-versions }}
python-version: 3.9
- name: Install dependencies
run: |
@@ -61,12 +54,26 @@ jobs:
run: >-
ls -l
- name: build container
id: docker_build
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: log in to container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push dev
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:$VERSION, ghcr.io/${{ github.repository }}:latest
- name: create github release
id: create_release
@@ -79,26 +86,6 @@ jobs:
draft: false
prerelease: false
- name: push container image
run: |
IMAGE_ID=ghcr.io/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_ID:latest
- name: publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:

View File

@@ -4,12 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.7.3] - 2022-07-31
### Fixed
- Updated to the 4.0.0 version of pyunifiprotect
- Added rust to the container, and bumped it to alpine 3.16
## [0.7.2] - 2022-07-17
### Fixed
- Updated to the latest version of pyunifiprotect to fix issues introduced in unifi protect 2.1.1
## [0.7.1] - 2022-06-08
### Fixed
- Updated to the latest version of pyunifiprotect to fix issues introduced in unifi protect 2.0.1
- Updated documentation to include how to set up local user accounts on unifi protect
## [0.7.0] - 2022-03-26
### Added
- Added a the ability to change the way the clip files are structured via a template string.

View File

@@ -2,13 +2,13 @@
# $ poetry build
# $ docker build -t ghcr.io/ep1cman/unifi-protect-backup .
FROM ghcr.io/linuxserver/baseimage-alpine:3.15
FROM ghcr.io/linuxserver/baseimage-alpine:3.16
LABEL maintainer="ep1cman"
WORKDIR /app
COPY dist/unifi-protect-backup-0.8.0.tar.gz sdist.tar.gz
COPY dist/unifi-protect-backup-0.7.3.tar.gz sdist.tar.gz
RUN \
echo "**** install build packages ****" && \
@@ -17,7 +17,8 @@ RUN \
musl-dev \
jpeg-dev \
zlib-dev \
python3-dev && \
python3-dev \
cargo && \
echo "**** install packages ****" && \
apk add --no-cache \
rclone \

View File

@@ -184,12 +184,12 @@ In order to backup to cloud storage you need to provide a `rclone.conf` file.
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 rclone/rclone config
$ docker run -it --rm -v $PWD:/root/.config/rclone --entrypoint rclone ghcr.io/ep1cman/unifi-protect-backup config
```
Follow the interactive configuration proceed, this will create a `rclone.conf`
file in your current directory.
Finally start the container:
Finally, start the container:
```
docker run \
-e UFP_USERNAME='USERNAME' \
@@ -198,10 +198,35 @@ docker run \
-e UFP_SSL_VERIFY='false' \
-e RCLONE_DESTINATION='my_remote:/unifi_protect_backup' \
-v '/path/to/save/clips':'/data' \
-v `/path/to/rclone.conf':'/config/rclone.conf'
-v `/path/to/rclone.conf':'/config/rclone/rclone.conf'
ghcr.io/ep1cman/unifi-protect-backup
```
## Debugging
If you need to debug your rclone setup, you can invoke rclone directly like so:
```
docker run \
--rm \
-v /path/to/rclone.conf:/config/rclone/rclone.conf \
-e RCLONE_CONFIG='/config/rclone/rclone.conf' \
--entrypoint rclone \
ghcr.io/ep1cman/unifi-protect-backup \
{rclone subcommand as per: https://rclone.org/docs/#subcommands}
```
For example to check that your config file is being read properly and list the configured remotes:
```
docker run \
--rm \
-v /path/to/rclone.conf:/config/rclone/rclone.conf \
-e RCLONE_CONFIG='/config/rclone/rclone.conf' \
--entrypoint rclone \
ghcr.io/ep1cman/unifi-protect-backup \
listremotes
```
## Credits
- Heavily utilises [`pyunifiprotect`](https://github.com/briis/pyunifiprotect) by [@briis](https://github.com/briis/)

19
poetry.lock generated
View File

@@ -555,6 +555,14 @@ category = "main"
optional = true
python-versions = "*"
[[package]]
name = "orjson"
version = "3.7.10"
description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy"
category = "main"
optional = false
python-versions = ">=3.7"
[[package]]
name = "packaging"
version = "21.3"
@@ -861,7 +869,7 @@ tzdata = {version = "*", markers = "python_version >= \"3.6\""}
[[package]]
name = "pyunifiprotect"
version = "3.9.0"
version = "4.0.11"
description = "Unofficial UniFi Protect Python API and CLI"
category = "main"
optional = false
@@ -871,6 +879,7 @@ python-versions = "*"
aiofiles = "*"
aiohttp = "*"
aioshutil = "*"
orjson = "*"
packaging = "*"
pillow = "*"
pydantic = "!=1.9.1"
@@ -1241,7 +1250,7 @@ test = ["pytest", "black", "isort", "mypy", "flake8", "flake8-docstrings", "pyte
[metadata]
lock-version = "1.1"
python-versions = ">=3.9.0,<4.0"
content-hash = "7e206e8e7606eef53e11c90568cc20e1fd857fab1fc6bc6782f265ee429a73e9"
content-hash = "8a8ba8afef1dae213be16fa56b914cd35f56c70d034203c73f068dc7d1ae2268"
[metadata.files]
aiocron = [
@@ -1743,6 +1752,7 @@ nodeenv = [
{file = "nodeenv-1.6.0-py2.py3-none-any.whl", hash = "sha256:621e6b7076565ddcacd2db0294c0381e01fd28945ab36bcf00f41c5daf63bef7"},
{file = "nodeenv-1.6.0.tar.gz", hash = "sha256:3ef13ff90291ba2a4a7a4ff9a979b63ffdd00a464dbe04acf0ea6471517a4c2b"},
]
orjson = []
packaging = [
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
@@ -1920,10 +1930,7 @@ pytz-deprecation-shim = [
{file = "pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl", hash = "sha256:8314c9692a636c8eb3bda879b9f119e350e93223ae83e70e80c31675a0fdc1a6"},
{file = "pytz_deprecation_shim-0.1.0.post0.tar.gz", hash = "sha256:af097bae1b616dde5c5744441e2ddc69e74dfdcb0c263129610d85b87445a59d"},
]
pyunifiprotect = [
{file = "pyunifiprotect-3.9.0-py3-none-any.whl", hash = "sha256:b5629fe197899d6ddba6e0ff20db548f71c66207720439c489e6b2e1b4b34325"},
{file = "pyunifiprotect-3.9.0.tar.gz", hash = "sha256:a4e7beea33008207adaeb70104c68315ee35e22c32e8fc01b9bc128eef3f453c"},
]
pyunifiprotect = []
pywin32-ctypes = [
{file = "pywin32-ctypes-0.2.0.tar.gz", hash = "sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942"},
{file = "pywin32_ctypes-0.2.0-py2.py3-none-any.whl", hash = "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98"},

View File

@@ -1,7 +1,7 @@
[tool]
[tool.poetry]
name = "unifi-protect-backup"
version = "0.8.0"
version = "0.7.3"
homepage = "https://github.com/ep1cman/unifi-protect-backup"
description = "Python tool to backup unifi event clips in realtime."
authors = ["sebastian.goscik <sebastian@goscik.com>"]
@@ -39,7 +39,7 @@ pre-commit = {version = "^2.12.0", optional = true}
toml = {version = "^0.10.2", optional = true}
bump2version = {version = "^1.0.1", optional = true}
tox-asdf = {version = "^0.1.0", optional = true}
pyunifiprotect = "^3.2.1"
pyunifiprotect = "^4.0.11"
aiocron = "^1.8"
ipdb = {version = "^0.13.9", optional = true}
types-pytz = {version = "^2021.3.5", optional = true}

View File

@@ -2,6 +2,6 @@
__author__ = """sebastian.goscik"""
__email__ = 'sebastian@goscik.com'
__version__ = '0.8.0'
__version__ = '0.7.3'
from .unifi_protect_backup import UnifiProtectBackup