ZettaIO / restic-compose-backup

Automatic restic backup of a docker-compose setup. https://hub.docker.com/r/zettaio/restic-compose-backup
MIT License
29 stars 16 forks source link

Swarm mode and single container #43

Open jwaes opened 9 months ago

jwaes commented 9 months ago

When i enable SWARM_MODE everything works fine with labels in other stacks. But when i add a label to a single container in the docker host i get this error:

2024-02-15 09:42:42,947 - INFO: ------------------------- Detected Config -------------------------
2024-02-15 09:42:42,949 - INFO: service: web
2024-02-15 09:42:42,950 - INFO:  - volume: /var/lib/docker/volumes/restic-backup_test/_data -> /volumes/restic-backup/web/srv/tests
2024-02-15 09:42:42,951 - INFO: service: None
Traceback (most recent call last):
  File "/usr/bin/rcb", line 33, in <module>
    sys.exit(load_entry_point('restic-compose-backup', 'console_scripts', 'rcb')())
  File "/restic-compose-backup/restic_compose_backup/cli.py", line 30, in main
    status(config, containers)
  File "/restic-compose-backup/restic_compose_backup/cli.py", line 102, in status
    container.get_volume_backup_destination(mount, '/volumes'),
  File "/restic-compose-backup/restic_compose_backup/containers.py", line 245, in get_volume_backup_destination
    destination /= project_name
  File "/usr/lib/python3.7/pathlib.py", line 925, in __truediv__
    return self._make_child((key,))
  File "/usr/lib/python3.7/pathlib.py", line 704, in _make_child
    drv, root, parts = self._parse_args(args)
  File "/usr/lib/python3.7/pathlib.py", line 658, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
ERROR: 1

Need some defaults for projectname and for service name for not docker-compose containers.

einarf commented 9 months ago

Can you elaborate?

jwaes commented 9 months ago

@einarf

so when i have swarm mode enabled, and use the right labels in a docker-compose file all works fine.

But when i add a single container on that docker host, for example using portainer with the correct labels, as you can see above, while detecting the config, it finds this container, but gets 'None' for the service name. Because this 'single' container does not belong to a docker-compose stack.

Hope that is more clear.