fix: upload uncompressed boltdb when doing legacy full-restore (#194)
This commit is contained in:
@ -143,7 +143,12 @@ func (c Client) fullRestore(ctx context.Context, path string, legacy bool) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we can read both local metadata snapshots before
|
// Make sure we can read both local metadata snapshots before
|
||||||
kvBytes, err := readFileGzipped(path, c.manifest.KV)
|
readKv := readFileGzipped
|
||||||
|
if legacy {
|
||||||
|
// The legacy API didn't support gzipped uploads.
|
||||||
|
readKv = readFileGunzipped
|
||||||
|
}
|
||||||
|
kvBytes, err := readKv(path, c.manifest.KV)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to open local KV backup at %q: %w", filepath.Join(path, c.manifest.KV.FileName), err)
|
return fmt.Errorf("failed to open local KV backup at %q: %w", filepath.Join(path, c.manifest.KV.FileName), err)
|
||||||
}
|
}
|
||||||
@ -160,16 +165,17 @@ func (c Client) fullRestore(ctx context.Context, path string, legacy bool) error
|
|||||||
|
|
||||||
// Upload metadata snapshots to the server.
|
// Upload metadata snapshots to the server.
|
||||||
log.Println("INFO: Restoring KV snapshot")
|
log.Println("INFO: Restoring KV snapshot")
|
||||||
if err := c.PostRestoreKV(ctx).
|
kvReq := c.PostRestoreKV(ctx).ContentType("application/octet-stream").Body(kvBytes)
|
||||||
ContentEncoding("gzip").
|
if legacy {
|
||||||
ContentType("application/octet-stream").
|
kvReq = kvReq.ContentEncoding("gzip")
|
||||||
Body(kvBytes).
|
}
|
||||||
Execute(); err != nil {
|
if err := kvReq.Execute(); err != nil {
|
||||||
return fmt.Errorf("failed to restore KV snapshot: %w", err)
|
return fmt.Errorf("failed to restore KV snapshot: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should we have some way of wiping out any existing SQL on the server-side in the case when there is no backup?
|
// TODO: Should we have some way of wiping out any existing SQL on the server-side in the case when there is no backup?
|
||||||
if c.manifest.SQL != nil {
|
if c.manifest.SQL != nil {
|
||||||
|
// NOTE: No logic here to upload non-gzipped data because legacy=true doesn't support SQL restores.
|
||||||
log.Println("INFO: Restoring SQL snapshot")
|
log.Println("INFO: Restoring SQL snapshot")
|
||||||
if err := c.PostRestoreSQL(ctx).
|
if err := c.PostRestoreSQL(ctx).
|
||||||
ContentEncoding("gzip").
|
ContentEncoding("gzip").
|
||||||
|
Reference in New Issue
Block a user