Skip to content

Commit 7682500

Browse files
committed
Switch to croniter for cron validation
1 parent a34733e commit 7682500

15 files changed

+15
-18
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ venv
1919
/private/
2020
restic_data/
2121
restic_cache/
22-
restored_filestores
22+
live_two_filestores
2323
alerts.env
2424

2525
# build

docker-compose-backup-service.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ services:
1414
- ./restic_data:/restic_data
1515
# Map restic cache
1616
- ./restic_cache:/cache
17-
# Map in project source in dev
18-
- ./src:/restic-compose-backup
1917
networks:
2018
global:
2119
external: true

docker-compose-restore-test.yaml docker-compose-live-two.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ services:
77
restic-compose-backup.volumes: true
88
restic-compose-backup.volumes.include: "/tests"
99
volumes:
10-
- ./restored_filestores/src/tests:/srv/tests
11-
- ./restored_filestores/.vscode:/srv/code
10+
- ./live_two_filestores/src/tests:/srv/tests
11+
- ./live_two_filestores/.vscode:/srv/code
1212
environment:
1313
- SOME_VALUE=test
1414
- ANOTHER_VALUE=1
@@ -24,8 +24,8 @@ services:
2424
restic-compose-backup.volumes: true
2525
restic-compose-backup.volumes.exclude: "/tests"
2626
volumes:
27-
- ./restored_filestores/src/tests:/srv/tests
28-
- ./restored_filestores/.vscode:/srv/code
27+
- ./live_two_filestores/src/tests:/srv/tests
28+
- ./live_two_filestores/.vscode:/srv/code
2929
environment:
3030
- SOME_VALUE=test
3131
- ANOTHER_VALUE=1

restic_compose_backup.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RESTIC_KEEP_MONTHLY=12
1818
RESTIC_KEEP_YEARLY=3
1919

2020
LOG_LEVEL=info
21-
CRON_SCHEDULE=0,5,10,15,20,25,30,35,40,45,50,55 * * * *
21+
CRON_SCHEDULE=*/5 * * * *
2222

2323
# EMAIL_HOST=
2424
# EMAIL_PORT=

restore-backup.sh

-2
This file was deleted.

src/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ RUN apk update && apk add python3 \
88
py3-pip \
99
bash
1010
RUN python3 -m pip install --no-cache-dir pipx --break-system-packages
11-
1211
RUN python3 -m pipx ensurepath --global
1312
ADD . /restic-compose-backup
1413
WORKDIR /restic-compose-backup

src/crontab

-2
This file was deleted.

src/restic_compose_backup/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class Config:
55
default_backup_command = "source /env.sh && rcb backup > /proc/1/fd/1"
6-
default_crontab_schedule = "*/5 * * * *"
6+
default_crontab_schedule = "0 2 * * *"
77

88
"""Bag for config values"""
99
def __init__(self, check=True):

src/restic_compose_backup/cron.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from croniter import croniter
12
"""
23
# ┌───────────── minute (0 - 59)
34
# │ ┌───────────── hour (0 - 23)
@@ -20,7 +21,7 @@ def generate_crontab(config):
2021
if schedule:
2122
schedule = schedule.strip()
2223
schedule = strip_quotes(schedule)
23-
if not validate_schedule(schedule):
24+
if not croniter.is_valid(schedule):
2425
schedule = config.default_crontab_schedule
2526
else:
2627
schedule = config.default_crontab_schedule

src/setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
]),
1313
install_requires=[
1414
'docker~=7.1.0',
15+
'croniter~=5.0.1'
1516
],
1617
entry_points={'console_scripts': [
1718
'restic-compose-backup = restic_compose_backup.cli:main',

start-live-system.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
docker compose -p live-system -f docker-compose-backup-service.yaml -f docker-compose-live.yaml down -v
2-
docker compose -p live-system -f docker-compose-backup-service.yaml -f docker-compose-live.yaml up --build --force-recreate -d
1+
docker compose -p live -f docker-compose-backup-service.yaml -f docker-compose-live.yaml down -v
2+
docker compose -p live -f docker-compose-backup-service.yaml -f docker-compose-live.yaml up --build --force-recreate -d

start-live-two-with-restore.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docker compose -p live-two -f docker-compose-live-two.yaml -f docker-compose-restore-service.yaml down -v
2+
docker compose -p live-two -f docker-compose-live-two.yaml -f docker-compose-restore-service.yaml up --build --force-recreate -d

stop-backup-system.sh

-1
This file was deleted.

stop-live-two.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker compose -p restore-test -f docker-compose-live-two.yaml -f docker-compose-restore-service.yaml down

stop-live-system.sh stop-live.sh

File renamed without changes.

0 commit comments

Comments
 (0)