Compare commits
5 Commits
08e02d12db
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0086878d57 | ||
|
|
2ed9f3345d | ||
|
|
50dd0df84f | ||
|
|
e17894e49c | ||
|
|
326d2c0910 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,3 +1,6 @@
|
||||
__pycache__
|
||||
*.egg-info
|
||||
build/
|
||||
build/
|
||||
|
||||
.env
|
||||
key
|
||||
@@ -7,7 +7,7 @@ Purpose:
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Recommended to put these in the relevant `~/.bashrc` file
|
||||
Put these in a `.env` file in the directory that the backup will be run from.
|
||||
|
||||
| Env Variable | Description |
|
||||
|---------------------|--------------------------------------------------------------------------------------------|
|
||||
|
||||
@@ -12,4 +12,4 @@ authors = [
|
||||
license = { file = "LICENSE" }
|
||||
requires-python = ">=3.10"
|
||||
|
||||
dependencies = ["rich", "requests", "click"]
|
||||
dependencies = ["rich", "requests", "click", "docker", "python-dotenv"]
|
||||
|
||||
@@ -2,4 +2,6 @@ uv
|
||||
ruff
|
||||
rich
|
||||
requests
|
||||
click
|
||||
click
|
||||
docker
|
||||
python-dotenv
|
||||
@@ -81,6 +81,7 @@ def main(
|
||||
logging.getLogger('urllib3.connectionpool').setLevel('WARNING')
|
||||
|
||||
if project is not None and services is not None:
|
||||
logger.debug(f'Using project {project} and stopping services: {services}')
|
||||
decorator = manage_containers(project=project, services=services.split(','))
|
||||
func = decorator(run)
|
||||
else:
|
||||
@@ -96,4 +97,10 @@ def main(
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from dotenv import load_dotenv
|
||||
from pathlib import Path
|
||||
|
||||
dotenv_file = Path.cwd() / '.env'
|
||||
print(dotenv_file)
|
||||
load_dotenv(dotenv_path=dotenv_file)
|
||||
main()
|
||||
|
||||
@@ -15,11 +15,12 @@ def manage_containers(project: str, services: list[str]):
|
||||
try:
|
||||
project_containers = (
|
||||
c
|
||||
for c in client.containers.list()
|
||||
if c.labels['com.docker.compose.project'] == project
|
||||
for c in client.containers.list(all=True)
|
||||
if c.labels.get('com.docker.compose.project', False)
|
||||
)
|
||||
service_dict: dict[str, Container] = {
|
||||
c.labels['com.docker.compose.service']: c for c in project_containers
|
||||
service: c for c in project_containers
|
||||
if (service := c.labels.get('com.docker.compose.service', False))
|
||||
}
|
||||
containers: list[Container] = [service_dict[s] for s in services]
|
||||
except Exception as e:
|
||||
|
||||
@@ -95,4 +95,7 @@ def main(loki_url: str, dry_run: bool, **kwargs):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
main()
|
||||
|
||||
@@ -35,4 +35,7 @@ def main(loki_url: str = None):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user