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

feat(storage): restore tool #16352

Closed
wants to merge 6 commits into from
Closed

feat(storage): restore tool #16352

wants to merge 6 commits into from

Conversation

tmgordeeva
Copy link

Adds an offline restore tool to replace existing data and metadata with a backup.

Closes #15605
Closes #15606

@tmgordeeva tmgordeeva force-pushed the jgm-restore branch 3 times, most recently from 8606b7a to 55eb211 Compare January 8, 2020 18:27
jacobmarble and others added 2 commits January 8, 2020 10:45
Adds a restore tool which does offline restore of data and metadata.
Copy link
Contributor

@sebito91 sebito91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits and a couple of questions, but otherwise looks awesome to me!


func restoreEngine() error {
dataDir := filepath.Join(flags.enginePath, "/data")
if err := os.Mkdir(dataDir, 0777); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be os.MkdirAll(dataDir, 0777) in case we need to define parents?

return err
}

return os.Mkdir(flags.enginePath, 0777)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be os.MkdirAll(flags.enginePath, 0777) to ensure the parents are made too. Since we check to see if /var/lib/path/to/data/engine exists in L145, we should make sure that this is fully created. Alternatively if we're just changing the perms we should use Chmod?

https://golang.org/pkg/os/#Chmod

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not worry about chmod'ing an existing dir here. I agree that MkdirAll makes sense.

cmd/influxd/restore/command.go Show resolved Hide resolved
Copy link
Member

@jacobmarble jacobmarble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, found a few small issues. I would like to test this out before it gets merged. I'll comment when I've done that.

return err
}

return os.Mkdir(flags.enginePath, 0777)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not worry about chmod'ing an existing dir here. I agree that MkdirAll makes sense.


func restoreBolt() error {
backupBolt := filepath.Join(flags.backupPath, bolt.DefaultFilename)
f, err := os.OpenFile(backupBolt, os.O_RDONLY, 0666)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use os.Open instead.

}
defer f.Close()

w, err := os.OpenFile(flags.boltPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(do not use os.Open here, as the file is opened for writing)

count := 0
err := filepath.Walk(flags.backupPath, func(path string, info os.FileInfo, err error) error {
if strings.Contains(path, ".tsm") {
f, err := os.OpenFile(path, os.O_RDONLY, 0600)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use os.Open

@tmgordeeva
Copy link
Author

Tested by creating a backup, restoring and verifying:

  • Engine starts and sample queries return equivalent results
  • TSM files are the same
  • Regenerated series files appear the same up to order

Copy link
Contributor

@sebito91 sebito91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more fix to the MkdirAll and it's good to go from me!

return err
}

return os.Mkdir(flags.enginePath, 0777)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one still should be changed to MkdirAll

@tmgordeeva tmgordeeva requested a review from sebito91 January 10, 2020 20:46
Copy link
Contributor

@sebito91 sebito91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jacobmarble
Copy link
Member

Replaced by #16504

@jacobmarble jacobmarble deleted the jgm-restore branch January 11, 2020 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

storage 2.0: implement meta data restore from backup storage 2.0: implement data restore from backup
3 participants