Skip to content
Merged
44 changes: 34 additions & 10 deletions api/api_backup.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions api/contract/overrides/paths/backup_metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ get:
enum:
- gzip
- identity
- in: header
name: Gzip-Compression-Level
description: The gzip compression level to use when compressing the response.
schema:
type: string
enum:
- none
- default
- speedy
- full
responses:
"200":
description: Snapshot of metadata
Expand Down
2 changes: 1 addition & 1 deletion api/model_influxql_json_response.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 43 additions & 4 deletions api/model_influxql_json_response_results.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions api/model_influxql_json_response_series.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions api/model_script_language.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions clients/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ type Params struct {

// Compression to use for local copies of snapshot files.
Compression br.FileCompression

// ServerGzipCompressionLevel controls the server-side gzip compression level.
// Valid values: "default", "full", "speedy", "none".
ServerGzipCompressionLevel string
}

func (p *Params) matches(bkt api.BucketMetadataManifest) bool {
Expand Down Expand Up @@ -98,7 +102,11 @@ func (c *Client) Backup(ctx context.Context, params *Params) error {
// are parsed into a slice for additional processing.
func (c *Client) downloadMetadata(ctx context.Context, params *Params) error {
log.Println("INFO: Downloading metadata snapshot")
rawResp, err := c.GetBackupMetadata(ctx).AcceptEncoding("gzip").Execute()
req := c.GetBackupMetadata(ctx).AcceptEncoding("gzip")
if params.ServerGzipCompressionLevel != "" {
req = req.GzipCompressionLevel(params.ServerGzipCompressionLevel)
}
rawResp, err := req.Execute()
if err != nil {
return fmt.Errorf("failed to download metadata snapshot: %w", err)
}
Expand Down Expand Up @@ -297,7 +305,11 @@ func (c *Client) downloadBucketData(ctx context.Context, params *Params) error {
// to a local file, and its metadata is returned for aggregation.
func (c Client) downloadShardData(ctx context.Context, params *Params, shardId int64) (*br.ManifestFileEntry, error) {
log.Printf("INFO: Backing up TSM for shard %d", shardId)
res, err := c.GetBackupShardId(ctx, shardId).AcceptEncoding("gzip").Execute()
req := c.GetBackupShardId(ctx, shardId).AcceptEncoding("gzip")
if params.ServerGzipCompressionLevel != "" {
req = req.GzipCompressionLevel(params.ServerGzipCompressionLevel)
}
res, err := req.Execute()
Comment thread
devanbenz marked this conversation as resolved.
if err != nil {
if apiError, ok := err.(api.ApiError); ok {
if apiError.ErrorCode() == api.ERRORCODE_NOT_FOUND {
Expand Down
13 changes: 12 additions & 1 deletion cmd/influx/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ Examples:
},
&cli.GenericFlag{
Name: "compression",
Usage: "Compression to use for local backup files, either 'none' or 'gzip'",
Usage: "Compression to use for local backup files on the client-side, either 'none' or 'gzip'. When -gzip-compression-level is set to 'none' this defaults to 'none'",
Value: &params.Compression,
},
&cli.StringFlag{
Name: "gzip-compression-level",
Usage: "The level of gzip compression for server-side backup: 'default', 'full' (best compression), 'speedy' (fastest), or 'none'",
Destination: &params.ServerGzipCompressionLevel,
},
Comment thread
devanbenz marked this conversation as resolved.
),
Action: func(ctx *cli.Context) error {
Comment thread
devanbenz marked this conversation as resolved.
if err := checkOrgFlags(&params.OrgParams); err != nil {
Expand All @@ -52,6 +57,12 @@ Examples:
}
params.Path = ctx.Args().Get(0)

// If the user requested no server-side compression and didn't
// explicitly set local compression, skip local gzip too.
if params.ServerGzipCompressionLevel == "none" && !ctx.IsSet("compression") {
params.Compression = br.NoCompression
}

api := getAPI(ctx)
client := backup.Client{
CLI: getCLI(ctx),
Expand Down