Skip to content

Commit ed790f4

Browse files
committed
Support encryuption only for remote backup
1 parent e6de9e4 commit ed790f4

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/pg_probackup.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static void opt_backup_mode(ConfigOption *opt, const char *arg);
135135
static void opt_show_format(ConfigOption *opt, const char *arg);
136136

137137
static void compress_init(void);
138+
static void encryption_init(void);
138139

139140
/*
140141
* Short name should be non-printable ASCII character.
@@ -600,9 +601,8 @@ main(int argc, char *argv[])
600601
if (num_threads < 1)
601602
num_threads = 1;
602603

604+
encryption_init();
603605
compress_init();
604-
if (instance_config.encryption)
605-
fio_crypto_init();
606606

607607
/* do actual operation */
608608
switch (backup_subcmd)
@@ -714,6 +714,23 @@ opt_show_format(ConfigOption *opt, const char *arg)
714714
elog(ERROR, "Invalid show format \"%s\"", arg);
715715
}
716716

717+
/*
718+
* Initialize encryption support.
719+
*/
720+
static void encryption_init(void)
721+
{
722+
if (encryption_shortcut)
723+
instance_config.encryption = encryption_shortcut;
724+
725+
if (instance_config.encryption)
726+
{
727+
if (!instance_config.remote.host)
728+
elog(ERROR, "Encryp;tion is upported only for remote backups");
729+
730+
fio_crypto_init();
731+
}
732+
}
733+
717734
/*
718735
* Initialize compress and sanity checks for compress.
719736
*/
@@ -724,9 +741,6 @@ compress_init(void)
724741
if (compress_shortcut)
725742
instance_config.compress_alg = ZLIB_COMPRESS;
726743

727-
if (encryption_shortcut)
728-
instance_config.encryption = encryption_shortcut;
729-
730744
if (backup_subcmd != SET_CONFIG_CMD)
731745
{
732746
if (instance_config.compress_level != COMPRESS_LEVEL_DEFAULT

0 commit comments

Comments
 (0)