@ -14,6 +14,7 @@ our ($tde_template_dir);
BEGIN
{
$ ENV { TDE_MODE_NOSKIP } = 0 unless defined ( $ ENV { TDE_MODE_NOSKIP } ) ;
$ ENV { TDE_MODE_WAL } = 1 unless defined ( $ ENV { TDE_MODE_WAL } ) ;
}
sub init
@ -27,6 +28,12 @@ sub init
$ self - > _tde_init_principal_key ;
if ( $ ENV { TDE_MODE_WAL } )
{
$ self - > SUPER:: append_conf ( 'postgresql.conf' ,
'pg_tde.wal_encrypt = on' ) ;
}
return ;
}
@ -45,6 +52,63 @@ sub append_conf
$ self - > SUPER:: append_conf ( $ filename , $ str ) ;
}
sub backup
{
my ( $ self , $ backup_name , % params ) = @ _ ;
my $ backup_dir = $ self - > backup_dir . '/' . $ backup_name ;
mkdir $ backup_dir or die "mkdir($backup_dir) failed: $!" ;
if ( $ ENV { TDE_MODE_WAL } )
{
PostgreSQL::Test::Utils:: system_log ( 'cp' , '-R' , '-P' , '-p' ,
$ self - > pg_tde_dir , $ backup_dir . '/pg_tde' , ) ;
# TODO: More thorough checking for options incompatible with --encrypt-wal
$ params { backup_options } = [] unless defined $ params { backup_options } ;
unless (
List::Util:: any { $ _ eq '-Ft' or $ _ eq '-Xnone' }
@ { $ params { backup_options } } )
{
push @ { $ params { backup_options } } , '--encrypt-wal' ;
}
}
$ self - > SUPER:: backup ( $ backup_name , % params ) ;
}
sub enable_archiving
{
my ( $ self ) = @ _ ;
my $ path = $ self - > archive_dir ;
$ self - > SUPER:: enable_archiving ;
if ( $ ENV { TDE_MODE_WAL } )
{
$ self - > adjust_conf ( 'postgresql.conf' , 'archive_command' ,
qq( 'pg_tde_archive_decrypt %f %p "cp \\"%%p\\" \\"$path/%%f\\""' )
) ;
}
return ;
}
sub enable_restoring
{
my ( $ self , $ root_node , $ standby ) = @ _ ;
my $ path = $ root_node - > archive_dir ;
$ self - > SUPER:: enable_restoring ( $ root_node , $ standby ) ;
if ( $ ENV { TDE_MODE_WAL } )
{
$ self - > adjust_conf ( 'postgresql.conf' , 'restore_command' ,
qq( 'pg_tde_restore_encrypt %f %p "cp \\"$path/%%f\\" \\"%%p\\""' )
) ;
}
return ;
}
sub pg_tde_dir
{
my ( $ self ) = @ _ ;