diff --git a/README.md b/README.md index 4e59afc..6a9bb1c 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ This includes both host mapped volumes and actual docker volumes. * When backup starts a new instance of the container is created mapping in all the needed volumes. It will copy networks etc to ensure databases can be reached -* Volumes are mounted to `/backup//` - in the backup process container. `/backup` is pushed into restic +* Volumes are mounted to `/volumes//` + in the backup process container. `/volumes` is pushed into restic * Databases are backed up from stdin / dumps * Cron triggers backup @@ -117,7 +117,7 @@ volumes: Will dump databases directly into restic through stdin. They will appear in restic as a separate snapshot with -path `/backup//dump.sql` or similar. +path `/databases//dump.sql` or similar. ```yaml mariadb: diff --git a/restic_compose_backup/cli.py b/restic_compose_backup/cli.py index 05849da..1faa231 100644 --- a/restic_compose_backup/cli.py +++ b/restic_compose_backup/cli.py @@ -82,7 +82,7 @@ def backup(config, containers): volumes = containers.this_container.volumes # Map volumes from other containers we are backing up - mounts = containers.generate_backup_mounts('/backup') + mounts = containers.generate_backup_mounts('/volumes') volumes.update(mounts) result = backup_runner.run( @@ -123,7 +123,7 @@ def start_backup_process(config, containers): # Back up volumes try: logger.info('Backing up volumes') - vol_result = restic.backup_files(config.repository, source='/backup') + vol_result = restic.backup_files(config.repository, source='/volumes') logger.debug('Volume backup exit code: %s', vol_result) if vol_result != 0: logger.error('Backup command exited with non-zero code: %s', vol_result) diff --git a/restic_compose_backup/commands.py b/restic_compose_backup/commands.py index 539afca..fad7947 100644 --- a/restic_compose_backup/commands.py +++ b/restic_compose_backup/commands.py @@ -6,7 +6,7 @@ logger = logging.getLogger(__name__) def test(): - return run_command(['ls', '/backup']) + return run_command(['ls', '/volumes']) def ping_mysql(host, port, username, password) -> int: diff --git a/restic_compose_backup/containers.py b/restic_compose_backup/containers.py index aeeea7b..ee1d971 100644 --- a/restic_compose_backup/containers.py +++ b/restic_compose_backup/containers.py @@ -163,6 +163,7 @@ class Container: if self._include: for mount in self._mounts: for pattern in self._include: + print(pattern, self._include) if pattern in mount.source: break else: @@ -182,7 +183,7 @@ class Container: return filtered - def volumes_for_backup(self, source_prefix='/backup', mode='ro'): + def volumes_for_backup(self, source_prefix='/volumes', mode='ro'): """Get volumes configured for backup""" mounts = self.filter_mounts() volumes = {} @@ -333,7 +334,7 @@ class RunningContainers: """Obtain all containers with backup enabled""" return [container for container in self.containers if container.backup_enabled] - def generate_backup_mounts(self, dest_prefix='/backup') -> dict: + def generate_backup_mounts(self, dest_prefix='/volumes') -> dict: """Generate mounts for backup for the entire compose setup""" mounts = {} for container in self.containers_for_backup(): diff --git a/restic_compose_backup/containers_db.py b/restic_compose_backup/containers_db.py index abc4904..9321396 100644 --- a/restic_compose_backup/containers_db.py +++ b/restic_compose_backup/containers_db.py @@ -45,7 +45,7 @@ class MariadbContainer(Container): config = Config() return restic.backup_from_stdin( config.repository, - f'/backup/{self.service_name}/all_databases.sql', + f'/databases/{self.service_name}/all_databases.sql', self.dump_command(), ) @@ -88,7 +88,7 @@ class MysqlContainer(Container): config = Config() return restic.backup_from_stdin( config.repository, - f'/backup/{self.service_name}/all_databases.sql', + f'/databases/{self.service_name}/all_databases.sql', self.dump_command(), ) @@ -135,6 +135,6 @@ class PostgresContainer(Container): with utils.environment('PGPASSWORD', creds['password']): return restic.backup_from_stdin( config.repository, - f"/backup/{self.service_name}/{creds['database']}.sql", + f"/databases/{self.service_name}/{creds['database']}.sql", self.dump_command(), ) diff --git a/restic_compose_backup/restic.py b/restic_compose_backup/restic.py index 028d8ab..4fe6d79 100644 --- a/restic_compose_backup/restic.py +++ b/restic_compose_backup/restic.py @@ -19,7 +19,7 @@ def init_repo(repository: str): ])) -def backup_files(repository: str, source='/backup'): +def backup_files(repository: str, source='/volumes'): return commands.run(restic(repository, [ "--verbose", "backup",