Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/borg/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -2785,7 +2785,7 @@ def recreate(self, archive_id, target_name, delete_original, comment=None):
target = self.create_target(archive, target_name)
if self.exclude_if_present or self.exclude_caches:
self.matcher_add_tagged_dirs(archive)
if self.matcher.empty() and not target.recreate_rechunkify and comment is None:
if self.matcher.empty() and not target.recreate_rechunkify and comment is None and self.timestamp is None:
# nothing to do
return False
self.process_items(archive, target)
Expand Down
12 changes: 9 additions & 3 deletions src/borg/testsuite/archiver/recreate_cmd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,24 @@ def test_recreate_keep_original_timestamp(archivers, request):
info_orig = cmd(archiver, "info", "-a", "test0").splitlines()
# this shall recreate the archive and keep the nominal timestamp
time.sleep(1)
cmd(archiver, "recreate", "test0", "--comment", "test")
cmd(archiver, "recreate", "-a", "test0", "--comment", "test")
info_recreated = cmd(archiver, "info", "-a", "test0").splitlines()
nominal_orig = next(item for item in info_orig if item.startswith("Time (nominal):"))
nominal_recreated = next(item for item in info_recreated if item.startswith("Time (nominal):"))
assert nominal_orig == nominal_recreated
# the recreated archive must still contain the original items.
assert "input/file1" in cmd(archiver, "list", "test0", "--short")


def test_recreate_with_given_timestamp(archivers, request):
archiver = request.getfixturevalue(archivers)
create_test_files(archiver.input_path)
cmd(archiver, "repo-create", RK_ENCRYPTION)
cmd(archiver, "create", "test0", "input")
# this shall recreate the archive with a different nominal timestamp
cmd(archiver, "recreate", "test0", "--timestamp", "1970-01-02T00:00:00", "--comment", "test")
# this shall recreate the archive with a different nominal timestamp.
# --timestamp is the only change requested, so this also checks that a timestamp
# change alone is enough to make recreate do the work instead of skipping the archive.
cmd(archiver, "recreate", "-a", "test0", "--timestamp", "1970-01-02T00:00:00")
info = cmd(archiver, "info", "-a", "test0").splitlines()
dtime = datetime(1970, 1, 2, 0, 0, 0).astimezone() # local time in local timezone
s_time = dtime.strftime("%Y-%m-%d %H:%M:.. %z").replace("+", r"\+")
Expand All @@ -267,6 +271,8 @@ def test_recreate_with_given_timestamp(archivers, request):
s_time = dtime.strftime("%Y-%m-%d %H:..:.. %z").replace("+", r"\+")
assert any([re.search(r"Time \(end\).+ %s" % s_time, item) for item in info])
assert any([re.search(r"Time \(start\).+ %s" % s_time, item) for item in info])
# the recreated archive must still contain the original items.
assert "input/file1" in cmd(archiver, "list", "test0", "--short")


def test_recreate_dry_run(archivers, request):
Expand Down
Loading