diff --git a/NEWS b/NEWS index c3f6a833..63185bd0 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.4.18 + * #253: Mount whole repositories via "borgmatic mount" without any "--archive" flag. + 1.4.17 * #235: Pass extra options directly to particular Borg commands, handy for Borg options that borgmatic does not yet support natively. Use "extra_borg_options" in the storage configuration diff --git a/borgmatic/borg/mount.py b/borgmatic/borg/mount.py index 4e700097..4fccbf9f 100644 --- a/borgmatic/borg/mount.py +++ b/borgmatic/borg/mount.py @@ -17,9 +17,9 @@ def mount_archive( remote_path=None, ): ''' - Given a local or remote repository path, an archive name, a filesystem mount point, zero or more - paths to mount from the archive, extra Borg mount options, a storage configuration dict, and - optional local and remote Borg paths, mount the archive onto the mount point. + Given a local or remote repository path, an optional archive name, a filesystem mount point, + zero or more paths to mount from the archive, extra Borg mount options, a storage configuration + dict, and optional local and remote Borg paths, mount the archive onto the mount point. ''' umask = storage_config.get('umask', None) lock_wait = storage_config.get('lock_wait', None) @@ -33,7 +33,7 @@ def mount_archive( + (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ()) + (('--foreground',) if foreground else ()) + (('-o', options) if options else ()) - + ('::'.join((repository, archive)),) + + (('::'.join((repository, archive)),) if archive else (repository,)) + (mount_point,) + (tuple(paths) if paths else ()) ) diff --git a/borgmatic/commands/arguments.py b/borgmatic/commands/arguments.py index 86794642..b2e9eabf 100644 --- a/borgmatic/commands/arguments.py +++ b/borgmatic/commands/arguments.py @@ -333,7 +333,7 @@ def parse_arguments(*unparsed_arguments): '--repository', help='Path of repository to use, defaults to the configured repository if there is only one', ) - mount_group.add_argument('--archive', help='Name of archive to mount', required=True) + mount_group.add_argument('--archive', help='Name of archive to mount') mount_group.add_argument( '--mount-point', metavar='PATH', diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index 0817a97e..3a1434dd 100644 --- a/borgmatic/commands/borgmatic.py +++ b/borgmatic/commands/borgmatic.py @@ -252,7 +252,13 @@ def run_actions( ) if 'mount' in arguments: if arguments['mount'].repository is None or repository == arguments['mount'].repository: - logger.info('{}: Mounting archive {}'.format(repository, arguments['mount'].archive)) + if arguments['mount'].archive: + logger.info( + '{}: Mounting archive {}'.format(repository, arguments['mount'].archive) + ) + else: + logger.info('{}: Mounting repository'.format(repository)) + borg_mount.mount_archive( repository, arguments['mount'].archive, diff --git a/docs/how-to/extract-a-backup.md b/docs/how-to/extract-a-backup.md index 6270d4d9..c45a3df3 100644 --- a/docs/how-to/extract-a-backup.md +++ b/docs/how-to/extract-a-backup.md @@ -100,6 +100,12 @@ borgmatic mount --archive host-2019-... --mount-point /mnt This mounts the entire archive on the given mount point `/mnt`, so that you can look in there for your files. +Omit the `--archive` flag to mount all archives (lazy-loaded): + +```bash +borgmatic mount --mount-point /mnt +``` + If you'd like to restrict the mounted filesystem to only particular paths from your archive, use the `--path` flag, similar to the `extract` action above. For instance: diff --git a/setup.py b/setup.py index 5f60951d..9ff3ba3a 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = '1.4.17' +VERSION = '1.4.18' setup( diff --git a/tests/integration/commands/test_arguments.py b/tests/integration/commands/test_arguments.py index 5a432be0..9c5bb948 100644 --- a/tests/integration/commands/test_arguments.py +++ b/tests/integration/commands/test_arguments.py @@ -352,13 +352,6 @@ def test_parse_arguments_requires_archive_with_extract(): module.parse_arguments('--config', 'myconfig', 'extract') -def test_parse_arguments_requires_archive_with_mount(): - flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default']) - - with pytest.raises(SystemExit): - module.parse_arguments('--config', 'myconfig', 'mount', '--mount-point', '/mnt') - - def test_parse_arguments_requires_archive_with_restore(): flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])