diff --git a/src/butter_backup/backup_backends.py b/src/butter_backup/backup_backends.py index 3018dea..14a64e9 100644 --- a/src/butter_backup/backup_backends.py +++ b/src/butter_backup/backup_backends.py @@ -57,7 +57,6 @@ def do_backup(self, mount_dir: Path) -> None: files_dest.mkdir(parents=True, exist_ok=True) for src in self.config.Files: self.rsync_file(src, files_dest) - self.sync_filesystem_changes(mount_dir) @staticmethod def get_source_snapshot(root: Path) -> Path: @@ -108,11 +107,6 @@ def rsync_file(src: Path, dest: Path) -> None: cmd: sh.StrPathList = ["sudo", "rsync", "-ax", "--inplace", src, dest] sh.run_cmd(cmd=cmd) - @staticmethod - def sync_filesystem_changes(mount_dir: Path) -> None: - sync_cmd: sh.StrPathList = ["sudo", "btrfs", "filesystem", "sync", mount_dir] - sh.run_cmd(cmd=sync_cmd) - @staticmethod def rsync_folder( src: Path, dest: Path, maybe_exclude_patterns: Path | None @@ -153,11 +147,6 @@ def adapt_ownership(backup_repository: Path) -> None: ) sdm.chown(backup_repository, user, group, recursive=True) - @staticmethod - def sync_filesystem_changes(mount_dir: Path) -> None: - sync_cmd: sh.StrPathList = ["sudo", "sync", "-f", mount_dir] - sh.run_cmd(cmd=sync_cmd) - def copy_files(self, backup_repository: Path) -> None: restic_cmd: sh.StrPathList = [ "sudo", @@ -171,4 +160,3 @@ def copy_files(self, backup_repository: Path) -> None: restic_cmd.extend(["--exclude-file", self.config.ExcludePatternsFile]) restic_cmd.extend(list(self.config.FilesAndFolders)) sh.pipe_pass_cmd_to_real_cmd(self.config.RepositoryPassCmd, restic_cmd) - self.sync_filesystem_changes(backup_repository) diff --git a/src/butter_backup/cli.py b/src/butter_backup/cli.py index 81feb24..71dd2a4 100644 --- a/src/butter_backup/cli.py +++ b/src/butter_backup/cli.py @@ -169,17 +169,21 @@ def close(config: Path = CONFIG_OPTION, verbose: int = VERBOSITY_OPTION) -> None configurations = cp.parse_configuration(config.read_text()) mounted_devices = sdm.get_mounted_devices() for cfg in configurations: - mapped_device = str(cfg.map_name()) - if cfg.device().exists() and mapped_device in mounted_devices: - mount_dirs = mounted_devices[mapped_device] - if len(mount_dirs) != 1: - # TODO introduce custom exception - raise ValueError( - "Got several possible mount points. Expected exactly 1!" + map_name = cfg.map_name() + map_name_as_str = str(map_name) + if cfg.device().exists() and map_name_as_str in mounted_devices: + mount_dirs = mounted_devices[map_name_as_str] + num_mount_dirs = len(mount_dirs) + if num_mount_dirs != 1: + logger.error( + "Got {num_mount_dirs} mount points for device {device}. Expected" + " exactly 1! Skipping device.", + num_mount_dirs=num_mount_dirs, + device=cfg.Name, ) - mount_dir = next(iter(mount_dirs)) - sdm.unmount_device(mount_dir) - sdm.close_decrypted_device(Path(mapped_device)) + continue + sdm.unmount_device(map_name) + sdm.close_decrypted_device(map_name) @app.command()