From e6a8984c999102ef29221b2949435c215c1eacf4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 20 Jun 2022 19:43:13 +0200 Subject: [PATCH] borg (import|export)-tar NAME ... --- src/borg/archiver.py | 6 +++--- src/borg/testsuite/archiver.py | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index dd9f0e20d..fd6356268 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -4266,8 +4266,6 @@ def define_borg_mount(parser): formatter_class=argparse.RawDescriptionHelpFormatter, help='create tarball from archive') subparser.set_defaults(func=self.do_export_tar) - subparser.add_argument('--name', dest='name', metavar='NAME', type=NameSpec, - help='specify the archive name') subparser.add_argument('--tar-filter', dest='tar_filter', default='auto', help='filter program to pipe data through') subparser.add_argument('--list', dest='output_list', action='store_true', @@ -4275,6 +4273,8 @@ def define_borg_mount(parser): subparser.add_argument('--tar-format', metavar='FMT', dest='tar_format', default='GNU', choices=('BORG', 'PAX', 'GNU'), help='select tar format: BORG, PAX or GNU') + subparser.add_argument('name', metavar='NAME', type=NameSpec, + help='specify the archive name') subparser.add_argument('tarfile', metavar='FILE', help='output tar file. "-" to write to stdout instead.') subparser.add_argument('paths', metavar='PATH', nargs='*', type=str, @@ -5214,7 +5214,7 @@ def define_borg_mount(parser): help='select compression algorithm, see the output of the ' '"borg help compression" command for details.') - subparser.add_argument('--name', dest='name', metavar='NAME', type=NameSpec, + subparser.add_argument('name', metavar='NAME', type=NameSpec, help='specify the archive name') subparser.add_argument('tarfile', metavar='TARFILE', help='input tar file. "-" to read from stdin instead.') diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index 5512d0bfb..71fb0a064 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -1719,14 +1719,14 @@ def test_readonly_export_tar(self): with self.read_only(self.repository_path): # verify that command normally doesn't work with read-only repo if self.FORK_DEFAULT: - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=test', 'test.tar', exit_code=EXIT_ERROR) + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'test', 'test.tar', exit_code=EXIT_ERROR) else: with pytest.raises((LockFailed, RemoteRepository.RPCError)) as excinfo: - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=test', 'test.tar') + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'test', 'test.tar') if isinstance(excinfo.value, RemoteRepository.RPCError): assert excinfo.value.exception_class == 'LockFailed' # verify that command works with read-only repo when using --bypass-lock - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=test', 'test.tar', '--bypass-lock') + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'test', 'test.tar', '--bypass-lock') def test_readonly_extract(self): self.cmd(f'--repo={self.repository_location}', 'init', '--encryption=repokey') @@ -3364,7 +3364,7 @@ def test_export_tar(self): os.unlink('input/flagfile') self.cmd(f'--repo={self.repository_location}', 'init', '--encryption=repokey') self.cmd(f'--repo={self.repository_location}', 'create', 'test', 'input') - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=test', 'simple.tar', '--progress', '--tar-format=GNU') + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'test', 'simple.tar', '--progress', '--tar-format=GNU') with changedir('output'): # This probably assumes GNU tar. Note -p switch to extract permissions regardless of umask. subprocess.check_call(['tar', 'xpf', '../simple.tar', '--warning=no-timestamp']) @@ -3379,7 +3379,7 @@ def test_export_tar_gz(self): os.unlink('input/flagfile') self.cmd(f'--repo={self.repository_location}', 'init', '--encryption=repokey') self.cmd(f'--repo={self.repository_location}', 'create', 'test', 'input') - list = self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=test', 'simple.tar.gz', + list = self.cmd(f'--repo={self.repository_location}', 'export-tar', 'test', 'simple.tar.gz', '--list', '--tar-format=GNU') assert 'input/file1\n' in list assert 'input/dir2\n' in list @@ -3395,7 +3395,7 @@ def test_export_tar_strip_components(self): os.unlink('input/flagfile') self.cmd(f'--repo={self.repository_location}', 'init', '--encryption=repokey') self.cmd(f'--repo={self.repository_location}', 'create', 'test', 'input') - list = self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=test', 'simple.tar', + list = self.cmd(f'--repo={self.repository_location}', 'export-tar', 'test', 'simple.tar', '--strip-components=1', '--list', '--tar-format=GNU') # --list's path are those before processing with --strip-components assert 'input/file1\n' in list @@ -3408,7 +3408,7 @@ def test_export_tar_strip_components(self): @requires_gnutar def test_export_tar_strip_components_links(self): self._extract_hardlinks_setup() - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=test', 'output.tar', + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'test', 'output.tar', '--strip-components=2', '--tar-format=GNU') with changedir('output'): subprocess.check_call(['tar', 'xpf', '../output.tar', '--warning=no-timestamp']) @@ -3421,7 +3421,7 @@ def test_export_tar_strip_components_links(self): @requires_gnutar def test_extract_hardlinks_tar(self): self._extract_hardlinks_setup() - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=test', 'output.tar', 'input/dir1', '--tar-format=GNU') + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'test', 'output.tar', 'input/dir1', '--tar-format=GNU') with changedir('output'): subprocess.check_call(['tar', 'xpf', '../output.tar', '--warning=no-timestamp']) assert os.stat('input/dir1/hardlink').st_nlink == 2 @@ -3434,8 +3434,8 @@ def test_import_tar(self, tar_format='PAX'): os.unlink('input/flagfile') self.cmd(f'--repo={self.repository_location}', 'init', '--encryption=none') self.cmd(f'--repo={self.repository_location}', 'create', 'src', 'input') - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=src', 'simple.tar', f'--tar-format={tar_format}') - self.cmd(f'--repo={self.repository_location}', 'import-tar', '--name=dst', 'simple.tar') + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'src', 'simple.tar', f'--tar-format={tar_format}') + self.cmd(f'--repo={self.repository_location}', 'import-tar', 'dst', 'simple.tar') with changedir(self.output_path): self.cmd(f'--repo={self.repository_location}', 'extract', 'dst') self.assert_dirs_equal('input', 'output/input', ignore_ns=True, ignore_xattrs=True) @@ -3448,8 +3448,8 @@ def test_import_tar_gz(self, tar_format='GNU'): os.unlink('input/flagfile') self.cmd(f'--repo={self.repository_location}', 'init', '--encryption=none') self.cmd(f'--repo={self.repository_location}', 'create', 'src', 'input') - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=src', 'simple.tgz', f'--tar-format={tar_format}') - self.cmd(f'--repo={self.repository_location}', 'import-tar', '--name=dst', 'simple.tgz') + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'src', 'simple.tgz', f'--tar-format={tar_format}') + self.cmd(f'--repo={self.repository_location}', 'import-tar', 'dst', 'simple.tgz') with changedir(self.output_path): self.cmd(f'--repo={self.repository_location}', 'extract', 'dst') self.assert_dirs_equal('input', 'output/input', ignore_ns=True, ignore_xattrs=True) @@ -3458,8 +3458,8 @@ def test_roundtrip_pax_borg(self): self.create_test_files() self.cmd(f'--repo={self.repository_location}', 'init', '--encryption=none') self.cmd(f'--repo={self.repository_location}', 'create', 'src', 'input') - self.cmd(f'--repo={self.repository_location}', 'export-tar', '--name=src', 'simple.tar', '--tar-format=BORG') - self.cmd(f'--repo={self.repository_location}', 'import-tar', '--name=dst', 'simple.tar') + self.cmd(f'--repo={self.repository_location}', 'export-tar', 'src', 'simple.tar', '--tar-format=BORG') + self.cmd(f'--repo={self.repository_location}', 'import-tar', 'dst', 'simple.tar') with changedir(self.output_path): self.cmd(f'--repo={self.repository_location}', 'extract', 'dst') self.assert_dirs_equal('input', 'output/input')