Skip to content

Commit f151227

Browse files
committed
add support for no compression
Signed-off-by: Avi Deitcher <avi@deitcher.net>
1 parent e160c24 commit f151227

File tree

7 files changed

+38
-3
lines changed

7 files changed

+38
-3
lines changed

cmd/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ S3: If it is a URL of the format s3://bucketname/path then it will connect via S
315315
flags.Bool("safechars", false, "The dump filename usually includes the character `:` in the date, to comply with RFC3339. Some systems and shells don't like that character. If true, will replace all `:` with `-`.")
316316

317317
// compression
318-
flags.String("compression", defaultCompression, "Compression to use. Supported are: `gzip`, `bzip2`")
318+
flags.String("compression", defaultCompression, "Compression to use. Supported are: `gzip`, `bzip2`, `none`")
319319

320320
// source filename pattern
321321
flags.String("filename-pattern", defaultFilenamePattern, "Pattern to use for filename in target. See documentation.")

cmd/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func restoreCmd(passedExecs execs, cmdConfig *cmdConfiguration) (*cobra.Command,
149149
}
150150

151151
// compression
152-
flags.String("compression", defaultCompression, "Compression to use. Supported are: `gzip`, `bzip2`")
152+
flags.String("compression", defaultCompression, "Compression to use. Supported are: `gzip`, `bzip2`, `none`")
153153

154154
// specific database to which to restore
155155
flags.String("database", "", "Mapping of from:to database names to which to restore, comma-separated, e.g. foo:bar,buz:qux. Replaces the `USE <database>` clauses in a backup file. If blank, uses the file as is.")

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The following are the environment variables, CLI flags and configuration file op
8787
| path-style addressing for S3 bucket instead of default virtual-host-style addressing | BR | `aws-path-style` | `AWS_PATH_STYLE` | `dump.targets[s3-target].pathStyle` | |
8888
| SMB username, used only if a target does not have one | BRP | `smb-user` | `SMB_USER` | `dump.targets[smb-target].username` | |
8989
| SMB password, used only if a target does not have one | BRP | `smb-pass` | `SMB_PASS` | `dump.targets[smb-target].password` | |
90-
| compression to use, one of: `bzip2`, `gzip` | BP | `compression` | `DB_DUMP_COMPRESSION` | `dump.compression` | `gzip` |
90+
| compression to use, one of: `bzip2`, `gzip`, `none` | BP | `compression` | `DB_DUMP_COMPRESSION` | `dump.compression` | `gzip` |
9191
| whether to include triggers, procedures and functions | B | `triggers-and-functions` | `DB_DUMP_TRIGGERS_AND_FUNCTIONS` | `dump.triggersAndFunctions` | `false` |
9292
| when in container, run the dump or restore with `nice`/`ionice` | BR | `` | `NICE` | `` | `false` |
9393
| filename to save the target backup file | B | `dump --filename-pattern` | `DB_DUMP_FILENAME_PATTERN` | `dump.filenamePattern` | |

pkg/compression/bzip2.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/dsnet/compress/bzip2"
77
)
88

9+
var _ Compressor = &Bzip2Compressor{}
10+
911
type Bzip2Compressor struct {
1012
}
1113

pkg/compression/compressor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ func GetCompressor(name string) (Compressor, error) {
1717
return &GzipCompressor{}, nil
1818
case "bzip2":
1919
return &Bzip2Compressor{}, nil
20+
case "none":
21+
return &NoCompressor{}, nil
2022
default:
2123
return nil, fmt.Errorf("unknown compression format: %s", name)
2224
}

pkg/compression/gzip.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"io"
66
)
77

8+
var _ Compressor = &GzipCompressor{}
9+
810
type GzipCompressor struct {
911
}
1012

pkg/compression/none.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package compression
2+
3+
import (
4+
"io"
5+
)
6+
7+
var _ Compressor = &NoCompressor{}
8+
9+
type NoCompressor struct {
10+
}
11+
12+
func (n *NoCompressor) Uncompress(in io.Reader) (io.Reader, error) {
13+
return in, nil
14+
}
15+
16+
func (n *NoCompressor) Compress(out io.Writer) (io.WriteCloser, error) {
17+
return &nopWriteCloser{out}, nil
18+
}
19+
func (n *NoCompressor) Extension() string {
20+
return "tar"
21+
}
22+
23+
type nopWriteCloser struct {
24+
io.Writer
25+
}
26+
27+
func (n *nopWriteCloser) Close() error {
28+
return nil
29+
}

0 commit comments

Comments
 (0)