dolthub / dolt

Dolt – Git for Data
Apache License 2.0
17.58k stars 498 forks source link

Feature: Support `restore` subcommand in `dolt_backup()` #8001

Closed fulghum closed 2 months ago

fulghum commented 2 months ago

The dolt_backup() stored procedure now supports the restore subcommand. Customers can use this support to create a new database from an existing backup, or to sync an existing database from a backup. Note that the restore subcommand currently requires root/superuser access to execute, since it can change database state (particular when the --force argument is used).

Example usage to create a database named db1 from a backup on disk:

call dolt_backup('restore', 'file:///opt/local/dolt-backups/db1', 'db1');

Related to https://github.com/dolthub/dolt/issues/7993

Fixes https://github.com/dolthub/dolt/issues/6074

timsehn commented 2 months ago

Will this also make dolt backup restore go through the SQL interface if a running server is detected? Or is that for later?

timsehn commented 2 months ago

Will this also make dolt backup restore go through the SQL interface if a running server is detected? Or is that for later?

Looks like no: https://github.com/dolthub/dolt/issues/7628

fulghum commented 2 months ago

Will this also make dolt backup restore go through the SQL interface if a running server is detected? Or is that for later?

Looks like no: #7628

Correct – #7628 tracks the next step to make the CLI command use the stored procedure. I figured we should get the stored procedure support out first so the customer had a non-dolt_clone approach for backups from within SQL, then follow up for the CLI conversion. Happy to look at that next.

timsehn commented 2 months ago

I think this user still would have hit the issue and gotten confused if it did not go through the SQL interface. Probably worth taking the few hours and cleaning it up tomorrow.

coffeegoddd commented 2 months ago

@fulghum DOLT

comparing_percentages
100.000000 to 100.000000
version result total
057e3c8 ok 5937457
version total_tests
057e3c8 5937457
correctness_percentage
100.0
fulghum commented 2 months ago

LGTM!

Maybe add some tests with backing up branches and working/staged changes. These all seem to work as expected when testing locally.

Thanks James! Good suggestion on more tests. I've got some more to add tomorrow (forwarding dolt backup to the stored procedure), so I'll take a look at extending the tests as part of that, too.

coffeegoddd commented 2 months ago

@fulghum DOLT

comparing_percentages
100.000000 to 100.000000
version result total
7f29618 ok 5937457
version total_tests
7f29618 5937457
correctness_percentage
100.0