Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force users to explicitly tell restore command to run without zero. #5206

Merged
merged 3 commits into from
Apr 14, 2020
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
12 changes: 10 additions & 2 deletions ee/backup/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var LsBackup x.SubCommand

var opt struct {
backupId, location, pdir, zero, keyfile string
forceZero bool
}

func init() {
Expand Down Expand Up @@ -107,6 +108,10 @@ $ dgraph restore -p . -l /var/backups/dgraph -z localhost:5080
"restore. If empty, it will restore the latest series.")
flag.StringVarP(&opt.keyfile, "keyfile", "k", "", "Key file to decrypt the backup. "+
"The same key is also used to re-encrypt the restored data.")
flag.BoolVarP(&opt.forceZero, "force_zero", "", true, "If false, no connection to "+
"a zero in the cluster will be required. Keep in mind this requires you to manually "+
"update the timestamp and max uid when you start the cluster. The correct values are "+
"printed near the end of this command's output.")
_ = Restore.Cmd.MarkFlagRequired("postings")
_ = Restore.Cmd.MarkFlagRequired("location")
}
Expand Down Expand Up @@ -169,8 +174,11 @@ func runRestoreCmd() error {
fmt.Println("Restoring backups from:", opt.location)
fmt.Println("Writing postings to:", opt.pdir)

// TODO: Remove this dependency on Zero. It complicates restore for the end
// user.
if opt.zero == "" && opt.forceZero {
return errors.Errorf("No Dgraph Zero address passed. Use the --force_zero option if you " +
"meant to do this")
}

if opt.zero != "" {
fmt.Println("Updating Zero timestamp at:", opt.zero)

Expand Down
2 changes: 1 addition & 1 deletion systest/backup/encryption/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func runRestore(t *testing.T, lastDir string, commitTs uint64) map[string]string
t.Logf("--- Restoring from: %q", localBackupDst)
testutil.KeyFile = "../../../ee/enc/enc-key"
argv := []string{"dgraph", "restore", "-l", localBackupDst, "-p", "data/restore",
"-k", testutil.KeyFile}
"-k", testutil.KeyFile, "--force_zero=false"}
cwd, err := os.Getwd()
require.NoError(t, err)
err = testutil.ExecWithOpts(argv, testutil.CmdOpts{Dir: cwd})
Expand Down
3 changes: 2 additions & 1 deletion systest/backup/minio/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ func runRestore(t *testing.T, lastDir string, commitTs uint64) map[string]string
require.NoError(t, os.RemoveAll(restoreDir))

t.Logf("--- Restoring from: %q", localBackupDst)
argv := []string{"dgraph", "restore", "-l", localBackupDst, "-p", "data/restore"}
argv := []string{"dgraph", "restore", "-l", localBackupDst, "-p", "data/restore",
"--force_zero=false"}
cwd, err := os.Getwd()
require.NoError(t, err)
err = testutil.ExecWithOpts(argv, testutil.CmdOpts{Dir: cwd})
Expand Down
9 changes: 6 additions & 3 deletions wiki/content/enterprise-features/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ The `--postings` (`-p`) flag sets the directory to which the restored posting
directories will be saved. This directory will contain a posting directory for
each group in the restored backup.

The `--zero` (`-z`) optional flag specifies a Dgraph Zero address to update the
start timestamp using the restored version. Otherwise, the timestamp must be
manually updated through Zero's HTTP 'assign' endpoint.
The `--zero` (`-z`) flag specifies a Dgraph Zero address to update the start
timestamp and UID lease using the restored version. If no zero address is
passed, the command will complain unless you set the value of the
`--force_zero` flag to false. If do not pass a zero value to this command,
the timestamp and UID lease must be manually updated through Zero's HTTP
'assign' endpoint using the values printed near the end of the command's output.

The `--backup_id` optional flag specifies the ID of the backup series to
restore. A backup series consists of a full backup and all the incremental
Expand Down