Skip to content

Commit

Permalink
reword options for cipher passphrase
Browse files Browse the repository at this point in the history
Use --cipher-pass (cli), cipher_pass (conf) and PGBK_CIPHER_PASS (env)
to give the passphase
  • Loading branch information
orgrim committed Dec 21, 2021
1 parent 50bb19b commit e1f5998
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -144,7 +144,7 @@ All the files procuded by a run of pg_back can be encrypted using age
(<https://age-encryption.org/> an easy to use tool that does authenticated
encryption of files). To keep things simple, encryption is done using a
passphrase. To encrypt files, use the `--encrypt` option along with the
`--cipher-pass` option or `PGBK_PASSPHRASE` environment variable to specify the
`--cipher-pass` option or `PGBK_CIPHER_PASS` environment variable to specify the
passphrase. When `encrypt` is set to true in the configuration file, the
`--no-encrypt` option allows to disable encryption on the command line. By
default, unencrypted source files are removed when they are successfully
Expand Down
4 changes: 2 additions & 2 deletions config.go
Expand Up @@ -317,7 +317,7 @@ func parseCli(args []string) (options, []string, error) {
changed = append(changed, "with-templates")
}

// To override cipher = true from the config file on the command line,
// To override encrypt = true from the config file on the command line,
// have MergeCliAndConfigOptions() use the false value
if *NoEncrypt {
opts.Encrypt = false
Expand Down Expand Up @@ -462,7 +462,7 @@ func loadConfigurationFile(path string) (options, error) {
opts.PreHook = s.Key("pre_backup_hook").MustString("")
opts.PostHook = s.Key("post_backup_hook").MustString("")
opts.Encrypt = s.Key("encrypt").MustBool(false)
opts.CipherPassphrase = s.Key("cipher_passphrase").MustString("")
opts.CipherPassphrase = s.Key("cipher_pass").MustString("")
opts.EncryptKeepSrc = s.Key("encrypt_keep_source").MustBool(false)

opts.Upload = s.Key("upload").MustString("none")
Expand Down
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -161,7 +161,7 @@ func run() (retVal error) {
// Ensure a non-empty passphrase is set when asking for encryption
if (opts.Encrypt || opts.Decrypt) && len(opts.CipherPassphrase) == 0 {
// Fallback on the environment
opts.CipherPassphrase = os.Getenv("PGBK_PASSPHRASE")
opts.CipherPassphrase = os.Getenv("PGBK_CIPHER_PASS")

if len(opts.CipherPassphrase) == 0 {
return fmt.Errorf("cannot use an empty passphrase for encryption")
Expand Down
4 changes: 2 additions & 2 deletions pg_back.conf
Expand Up @@ -57,9 +57,9 @@ checksum_algorithm = none
# Encrypt the files produced, including globals and configuration.
encrypt = false

# Passphrase to use for encryption and decryption. The PGBK_PASSPHRASE
# Passphrase to use for encryption and decryption. The PGBK_CIPHER_PASS
# environment variable can be used alternatively.
cipher_passphrase =
cipher_pass =

# Keep orignal files after encrypting them.
encrypt_keep_source = false
Expand Down

0 comments on commit e1f5998

Please sign in to comment.