mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-29 03:08:47 -06:00
Local file backup and restore working
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user