@@ -125,8 +125,8 @@ static int details(SSL* ssl, int socket, uint8_t compression, uint8_t encryption
125125static int ping (SSL * ssl , int socket , uint8_t compression , uint8_t encryption , int32_t output_format );
126126static int reset (SSL * ssl , int socket , uint8_t compression , uint8_t encryption , int32_t output_format );
127127static int reload (SSL * ssl , int socket , uint8_t compression , uint8_t encryption , int32_t output_format );
128- static int retain (SSL * ssl , int socket , char * server , char * backup_id , uint8_t compression , uint8_t encryption , int32_t output_format );
129- static int expunge (SSL * ssl , int socket , char * server , char * backup_id , uint8_t compression , uint8_t encryption , int32_t output_format );
128+ static int retain (SSL * ssl , int socket , char * server , char * backup_id , uint8_t compression , uint8_t encryption , bool cascade , int32_t output_format );
129+ static int expunge (SSL * ssl , int socket , char * server , char * backup_id , uint8_t compression , uint8_t encryption , bool cascade , int32_t output_format );
130130static int decrypt_data_client (char * from );
131131static int encrypt_data_client (char * from );
132132static int decompress_data_client (char * from );
@@ -199,6 +199,7 @@ usage(void)
199199 printf (" -C, --compress none|gz|zstd|lz4|bz2 Compress the wire protocol\n" );
200200 printf (" -E, --encrypt none|aes|aes256|aes192|aes128 Encrypt the wire protocol\n" );
201201 printf (" -s, --sort asc|desc Sort result (for list-backup)\n" );
202+ printf (" --cascade Cascadingly retain/expunge backups until the root base backup\n" );
202203 printf (" -?, --help Display help\n" );
203204 printf ("\n" );
204205 printf ("Commands:\n" );
@@ -459,6 +460,7 @@ main(int argc, char** argv)
459460 int optind = 0 ;
460461 int num_options = 0 ;
461462 int num_results = 0 ;
463+ bool cascade = false;
462464 char * sort_option = NULL ;
463465
464466 cli_option options [] = {
@@ -474,6 +476,7 @@ main(int argc, char** argv)
474476 {"C" , "compress" , true},
475477 {"E" , "encrypt" , true},
476478 {"s" , "sort" , true},
479+ {"" , "cascade" , false},
477480 {"?" , "help" , false}
478481 };
479482
@@ -621,6 +624,10 @@ main(int argc, char** argv)
621624 exit (1 );
622625 }
623626 }
627+ else if (!strcmp (optname , "cascade" ))
628+ {
629+ cascade = true;
630+ }
624631 else if (!strcmp (optname , "?" ) || !strcmp (optname , "help" ))
625632 {
626633 usage ();
@@ -912,11 +919,11 @@ main(int argc, char** argv)
912919 }
913920 else if (parsed .cmd -> action == MANAGEMENT_RETAIN )
914921 {
915- exit_code = retain (s_ssl , socket , parsed .args [0 ], parsed .args [1 ], compression , encryption , output_format );
922+ exit_code = retain (s_ssl , socket , parsed .args [0 ], parsed .args [1 ], compression , encryption , cascade , output_format );
916923 }
917924 else if (parsed .cmd -> action == MANAGEMENT_EXPUNGE )
918925 {
919- exit_code = expunge (s_ssl , socket , parsed .args [0 ], parsed .args [1 ], compression , encryption , output_format );
926+ exit_code = expunge (s_ssl , socket , parsed .args [0 ], parsed .args [1 ], compression , encryption , cascade , output_format );
920927 }
921928 else if (parsed .cmd -> action == MANAGEMENT_DECRYPT )
922929 {
@@ -1080,14 +1087,14 @@ static void
10801087help_retain (void )
10811088{
10821089 printf ("Retain a backup for a server\n" );
1083- printf (" pgmoneta-cli retain <server> <timestamp|oldest|newest>\n" );
1090+ printf (" pgmoneta-cli [--cascade] retain <server> <timestamp|oldest|newest>\n" );
10841091}
10851092
10861093static void
10871094help_expunge (void )
10881095{
10891096 printf ("Expunge a backup for a server\n" );
1090- printf (" pgmoneta-cli expunge <server> <timestamp|oldest|newest>\n" );
1097+ printf (" pgmoneta-cli [--cascade] expunge <server> <timestamp|oldest|newest>\n" );
10911098}
10921099
10931100static void
@@ -1507,9 +1514,9 @@ reload(SSL* ssl, int socket, uint8_t compression, uint8_t encryption, int32_t ou
15071514}
15081515
15091516static int
1510- retain (SSL * ssl , int socket , char * server , char * backup_id , uint8_t compression , uint8_t encryption , int32_t output_format )
1517+ retain (SSL * ssl , int socket , char * server , char * backup_id , uint8_t compression , uint8_t encryption , bool cascade , int32_t output_format )
15111518{
1512- if (pgmoneta_management_request_retain (ssl , socket , server , backup_id , compression , encryption , output_format ))
1519+ if (pgmoneta_management_request_retain (ssl , socket , server , backup_id , compression , encryption , cascade , output_format ))
15131520 {
15141521 goto error ;
15151522 }
@@ -1527,9 +1534,9 @@ retain(SSL* ssl, int socket, char* server, char* backup_id, uint8_t compression,
15271534}
15281535
15291536static int
1530- expunge (SSL * ssl , int socket , char * server , char * backup_id , uint8_t compression , uint8_t encryption , int32_t output_format )
1537+ expunge (SSL * ssl , int socket , char * server , char * backup_id , uint8_t compression , uint8_t encryption , bool cascade , int32_t output_format )
15311538{
1532- if (pgmoneta_management_request_expunge (ssl , socket , server , backup_id , compression , encryption , output_format ))
1539+ if (pgmoneta_management_request_expunge (ssl , socket , server , backup_id , compression , encryption , cascade , output_format ))
15331540 {
15341541 goto error ;
15351542 }
0 commit comments