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

Use gzip compression in backups. #3536

Merged
merged 1 commit into from
Jun 11, 2019
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
8 changes: 7 additions & 1 deletion ee/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package backup

import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -71,7 +72,8 @@ func (pr *Processor) WriteBackup(ctx context.Context) (*pb.BackupResponse, error

stream := pr.DB.NewStreamAt(pr.Request.ReadTs)
stream.LogPrefix = "Dgraph.Backup"
newSince, err := stream.Backup(handler, pr.Request.SinceTs)
gzWriter := gzip.NewWriter(handler)
newSince, err := stream.Backup(gzWriter, pr.Request.SinceTs)

if err != nil {
glog.Errorf("While taking backup: %v", err)
Expand All @@ -84,6 +86,10 @@ func (pr *Processor) WriteBackup(ctx context.Context) (*pb.BackupResponse, error
}

glog.V(2).Infof("Backup group %d version: %d", pr.Request.GroupId, pr.Request.ReadTs)
if err = gzWriter.Close(); err != nil {
glog.Errorf("While closing gzipped writer: %v", err)
return &emptyRes, err
}
if err = handler.Close(); err != nil {
glog.Errorf("While closing handler: %v", err)
return &emptyRes, err
Expand Down
7 changes: 6 additions & 1 deletion ee/backup/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package backup

import (
"compress/gzip"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -241,7 +242,11 @@ func RunRestore(pdir, location string) (uint64, error) {
fmt.Println("Creating new db:", bo.Dir)
}
}
return db.Load(r, 16)
gzReader, err := gzip.NewReader(r)
if err != nil {
return nil
}
return db.Load(gzReader, 16)
})
}

Expand Down