diff --git a/go/cmd/dolt/commands/backup.go b/go/cmd/dolt/commands/backup.go index 093296394e..4c2d443940 100644 --- a/go/cmd/dolt/commands/backup.go +++ b/go/cmd/dolt/commands/backup.go @@ -267,14 +267,6 @@ func syncBackup(ctx context.Context, dEnv *env.DoltEnv, apr *argparser.ArgParseR } func backup(ctx context.Context, dEnv *env.DoltEnv, b env.Remote) errhand.VerboseError { - metadata, err := env.GetMultiEnvStorageMetadata(dEnv.FS) - if err != nil { - return nil - } - if metadata.ArchiveFilesPresent() { - return errhand.BuildDError("error: archive files present. Please revert them with the --revert flag before running this command.").Build() - } - destDb, err := b.GetRemoteDB(ctx, dEnv.DoltDB(ctx).ValueReadWriter().Format(), dEnv) if err != nil { return errhand.BuildDError("error: unable to open destination.").AddCause(err).Build() diff --git a/go/store/nbs/archive_chunk_source.go b/go/store/nbs/archive_chunk_source.go index 23bb5d46d2..5f78485332 100644 --- a/go/store/nbs/archive_chunk_source.go +++ b/go/store/nbs/archive_chunk_source.go @@ -150,7 +150,14 @@ func (acs archiveChunkSource) currentSize() uint64 { } func (acs archiveChunkSource) reader(ctx context.Context) (io.ReadCloser, uint64, error) { - return nil, 0, errors.New("Archive chunk source does not support reader") + rdr := acs.aRdr.reader + chks, err := acs.count() + if err != nil { + return nil, 0, err + } + + rc := io.NewSectionReader(rdr, 0, int64(acs.currentSize())) + return io.NopCloser(rc), uint64(chks), nil } func (acs archiveChunkSource) uncompressedLen() (uint64, error) { return 0, errors.New("Archive chunk source does not support uncompressedLen") diff --git a/integration-tests/bats/archive.bats b/integration-tests/bats/archive.bats index d68b8695d4..6af2fd0e57 100755 --- a/integration-tests/bats/archive.bats +++ b/integration-tests/bats/archive.bats @@ -183,16 +183,6 @@ mutations_and_gc_statement() { run dolt sql -q 'select sum(i) from tbl;' [[ "$status" -eq 0 ]] || false [[ "$output" =~ "138075" ]] || false # i = 1 - 525, sum is 138075 - - - ## Temporary check. We want to ensure that backup will give an error, even when - ## there are archives in newgen. - mkdir ../backup - dolt backup add bac1 file://../backup - - run dolt backup sync bac1 - [ "$status" -eq 1 ] - [[ "$output" =~ "error: archive files present" ]] || false } @test "archive: can clone respiratory with mixed types" { @@ -269,3 +259,21 @@ mutations_and_gc_statement() { dolt fsck } +@test "archive: backup and restore" { + # cp the repository from the test dir. + mkdir -p original/.dolt + cp -R $BATS_TEST_DIRNAME/archive-test-repo/* original/.dolt + + cd original + dolt backup add bac1 file://../bac1 + dolt backup sync bac1 + + cd .. + + dolt backup restore file://./bac1 restored + cd restored + # Verify we can read data + run dolt sql -q 'select sum(i) from tbl;' + [[ "$status" -eq 0 ]] || false + [[ "$output" =~ "138075" ]] || false # i = 1 - 525, sum is 138075 +} \ No newline at end of file