From 7a647c06b7e9c18e5741e47a5ac3854c8616b157 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Wed, 17 Apr 2019 03:45:51 +0200 Subject: [PATCH] Upgrade to recent docker client --- restic_volume_backup/backup_runner.py | 9 +++++---- restic_volume_backup/cli.py | 10 +++++----- restic_volume_backup/utils.py | 2 +- setup.py | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/restic_volume_backup/backup_runner.py b/restic_volume_backup/backup_runner.py index bfb52f9..2ec535d 100644 --- a/restic_volume_backup/backup_runner.py +++ b/restic_volume_backup/backup_runner.py @@ -4,12 +4,13 @@ import docker from restic_volume_backup.config import Config def run(): - client = docker.Client(base_url=DOCKER_BASE_URL) + config = Config() + client = docker.DockerClient(base_url=config.docker_base_url) container = client.containers.run( - 'image', - 'command', - labels={"restic-volume-backup.backup_process": True}, + 'restic-volume-backup_backup', + 'echo "Hello"', + labels={"restic-volume-backup.backup_process": 'True'}, auto_remove=True, remove=True, detach=True, diff --git a/restic_volume_backup/cli.py b/restic_volume_backup/cli.py index ccad7e2..0fbba5b 100644 --- a/restic_volume_backup/cli.py +++ b/restic_volume_backup/cli.py @@ -3,6 +3,8 @@ import sys from restic_volume_backup.config import Config from restic_volume_backup.containers import RunningContainers +from restic_volume_backup import backup_runner +from restic_volume_backup import restic def main(): @@ -22,17 +24,15 @@ def main(): print() - elif args.mode == 'backup': + elif args.action == 'backup': print("Starting backup ..") # TODO: Errors when repo already exists - # restic.init_repo(Config.repository) + restic.init_repo(config.repository) + backup_runner.run() # for vol in containers.backup_volumes(): # restic.backup_volume(Config.repository, vol) - elif args.mode == 'snapshots': - restic.snapshots(config.repository) - def parse_args(): parser = argparse.ArgumentParser(prog='restic_volume_backup') diff --git a/restic_volume_backup/utils.py b/restic_volume_backup/utils.py index a709733..b3d0efb 100644 --- a/restic_volume_backup/utils.py +++ b/restic_volume_backup/utils.py @@ -6,7 +6,7 @@ from restic_volume_backup.config import Config def list_containers(): """Easily mockable container list""" config = Config() - client = docker.Client(base_url=config.docker_base_url) + client = docker.APIClient(base_url=config.docker_base_url) all_containers = client.containers() client.close() return all_containers diff --git a/setup.py b/setup.py index 2a5602e..14a40ac 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( author_email="eforselv@gmail.com", packages=find_namespace_packages(include=['restic_volume_backup']), install_requires=[ - 'docker-py==1.10.6', + 'docker==3.7.2', ], entry_points={'console_scripts': [ 'restic-volume-backup = restic_volume_backup.cli:main',