Skip to content

Commit 05b3070

Browse files
authored
Merge pull request #54 from homeylab/53-schedule
53 schedule
2 parents 54cc0e4 + 20cfee1 commit 05b3070

File tree

14 files changed

+59
-16
lines changed

14 files changed

+59
-16
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"features": {
88
"ghcr.io/devcontainers/features/python:1": {
99
"installTools": true,
10-
"version": "3.13.0"
10+
"version": "3.13.2"
1111
}
1212
},
1313
"customizations": {

.github/actions/python/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
- name: Set up Python
2424
uses: actions/setup-python@v3
2525
with:
26-
python-version: '3.13.0'
26+
python-version: '3.13.2'
2727
- name: Install Dependencies
2828
shell: bash
2929
run: |

.github/actions/tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88
- name: Set up Python
99
uses: actions/setup-python@v3
1010
with:
11-
python-version: '3.13.0'
11+
python-version: '3.13.2'
1212
- name: Install dependencies
1313
shell: bash
1414
run: |

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG BASE_IMAGE=python
2-
ARG BASE_IMAGE_TAG=3.13.0-slim-bookworm
2+
ARG BASE_IMAGE_TAG=3.13.2-slim-bookworm
33

44
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG}
55

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## DOCKER BUILD VARS
22
BASE_IMAGE=python
3-
BASE_IMAGE_TAG=3.13.0-slim-bookworm
3+
BASE_IMAGE_TAG=3.13.2-slim-bookworm
44
IMAGE_NAME=homeylab/bookstack-file-exporter
55
# keep this start sequence unique (IMAGE_TAG=)
66
# github actions will use this to create a tag

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ assets:
8787
The exporter can be installed via pip and run directly.
8888
8989
#### Python Version
90-
_Note: This application is tested and developed on Python version `3.13.X`. The min required version is >= `3.8` but is recommended to install (or set up a venv) a `3.13.X` version._
90+
_Note: This application is tested and developed on Python version `3.13.2`. The min required version is >= `3.8` but is recommended to install (or set up a venv) a `3.13.2` version._
9191

9292
#### Examples
9393
```bash
@@ -150,6 +150,11 @@ docker run \
150150
homeylab/bookstack-file-exporter:latest
151151
```
152152

153+
#### Docker Compose
154+
When using the configuration option: `run_interval`, a docker compose set up could be used to run the exporter as an always running application. The exporter will sleep and wait until `{run_interval}` seconds has elapsed before subsequent runs.
155+
156+
An example is shown in `examples/docker-compose.yaml`
157+
153158
#### Environment Variables
154159
See [Valid Environment Variables](#valid-environment-variables) for more options.
155160

@@ -256,6 +261,7 @@ More descriptions can be found for each section below:
256261
| `assets.export_meta` | `bool` | `false` | Optional (default: `false`), export of metadata about the page in a json file |
257262
| `assets.verify_ssl` | `bool` | `false` | Optional (default: `true`), whether or not to check ssl certificates when requesting content from Bookstack host |
258263
| `keep_last` | `int` | `false` | Optional (default: `None`), if exporter can delete older archives. valid values are:<br>- set to `-1` if you want to delete all archives after each run (useful if you only want to upload to object storage)<br>- set to `1+` if you want to retain a certain number of archives<br>- `0` will result in no action done |
264+
| `run_interval` | `int` | `false` | Optional (default: `0`). If specified, exporter will run in a loop and pause for `{run_interval}` seconds before subsequent runs. Example: `86400` seconds = `24` hours or run once a day. Setting this property to `0` will disable looping |
259265
| `minio` | `object` | `false` | Optional [Minio](#minio-backups) configuration options. |
260266

261267
#### Valid Environment Variables

bookstack_file_exporter/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main():
99
args: argparse.Namespace = run_args.get_args()
1010
logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s',
1111
level=run_args.get_log_level(args.log_level), datefmt='%Y-%m-%d %H:%M:%S')
12-
run.exporter(args)
12+
run.entrypoint(args)
1313

1414

1515
if __name__ == '__main__':

bookstack_file_exporter/config_helper/config_helper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ def __init__(self, args: argparse.Namespace):
5757
self._token_id, self._token_secret = self._generate_credentials()
5858
self._headers = self._generate_headers()
5959
self._urls = self._generate_urls()
60-
self._minio_access_key = ""
61-
self._minio_secret_key = ""
6260
self._object_storage_config = self._generate_remote_config()
6361

6462
def _generate_config(self, config_file: str) -> models.UserInput:

bookstack_file_exporter/config_helper/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class UserInput(BaseModel):
3636
credentials: Optional[BookstackAccess] = None
3737
formats: List[Literal["markdown", "html", "pdf", "plaintext"]]
3838
output_path: Optional[str] = None
39-
# export_meta: Optional[bool] = None
4039
assets: Optional[Assets] = Assets()
4140
minio: Optional[ObjectStorageConfig] = None
4241
keep_last: Optional[int] = None
42+
run_interval: Optional[int] = 0

bookstack_file_exporter/run.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import argparse
22
import sys
33
import logging
4+
import time
45
from typing import Dict
56

67
from bookstack_file_exporter.config_helper.config_helper import ConfigNode
@@ -10,10 +11,20 @@
1011

1112
log = logging.getLogger(__name__)
1213

13-
def exporter(args: argparse.Namespace):
14-
"""export bookstack nodes and archive locally and/or remotely"""
15-
## get configuration from helper
14+
def entrypoint(args: argparse.Namespace):
15+
"""entrypoint for export process"""
16+
# get configuration from helper
1617
config = ConfigNode(args)
18+
if config.user_inputs.run_interval:
19+
while True:
20+
exporter(config)
21+
log.info(f"Waiting {config.user_inputs.run_interval} seconds for next run")
22+
# sleep process state
23+
time.sleep(config.user_inputs.run_interval)
24+
exporter(config)
25+
26+
def exporter(config: ConfigNode):
27+
"""export bookstack nodes and archive locally and/or remotely"""
1728

1829
## convenience vars
1930
bookstack_headers = config.headers

examples/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ output_path: "bkps/"
5252
# set to 1+ if you want to retain a certain number of archives
5353
# set to 0 or comment out section if you want no action done
5454
keep_last: 5
55+
## optional - if specified exporter will run in a loop
56+
# it will run and then pause for {run_interval} seconds before running again
57+
# specify in seconds, example: 86400 seconds = 24 hours or run once a day
58+
# omit/commit out or set to 0 if you just want a single run and exit
59+
run_interval: 0

examples/docker-compose.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: bookstack-file-exporter
2+
services:
3+
bookstack-file-exporter:
4+
image: homeylab/bookstack-file-exporter:latest
5+
# use a uid/gid that has permissions to write to local dump directory
6+
user: 1000:1000
7+
container_name: bookstack-file-exporter
8+
environment:
9+
- LOG_LEVEL=info
10+
# example volumes shown
11+
# change the left side of the ':' to your preferred files/dir
12+
volumes:
13+
- /opt/bookstack/bkps/config.yml:/export/config/config.yml:ro
14+
- /opt/bookstack/bkps/archives:/export/dump
15+
# can also pass env variables as a file
16+
env_file:
17+
- bkp.env
18+
restart: always

examples/minio_config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,9 @@ clean_up: true
8282
# - this is useful if you only want to upload to object storage
8383
# set to 1+ if you want to retain a certain number of archives
8484
# set to 0 or comment out section if you want no action done
85-
keep_last: -1
85+
keep_last: -1
86+
## optional - if specified exporter will run in a loop
87+
# it will run and then pause for {run_interval} seconds before running again
88+
# specify in seconds, example: 86400 seconds = 24 hours or run once a day
89+
# omit/commit out or set to 0 if you just want a single run and exit
90+
run_interval: 0

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ classifiers =
1818
python_requires = >=3.8
1919
install_requires =
2020
Pyyaml >= 6.0.2 # https://pypi.org/project/PyYAML/
21-
Pydantic >= 2.9.2 # https://docs.pydantic.dev/latest/
21+
Pydantic >= 2.10.6 # https://docs.pydantic.dev/latest/
2222
requests >= 2.32.3 # https://pypi.org/project/requests/
23-
minio >= 7.2.10 # https://pypi.org/project/minio/
23+
minio >= 7.2.15 # https://pypi.org/project/minio/
2424
packages = find:
2525

2626
[options.entry_points]

0 commit comments

Comments
 (0)