From cc1d1edbac3f515a042bf3f8a4231bae9ea43983 Mon Sep 17 00:00:00 2001 From: Artur Zakirov Date: Mon, 27 Mar 2017 15:24:42 +0300 Subject: [PATCH] Change retention purge command finish message --- delete.c | 14 +++++++++----- pg_probackup.c | 2 +- restore.c | 6 ++++-- tests/expected/option_version.out | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/delete.c b/delete.c index 2cd0cf5b..471cd7ff 100644 --- a/delete.c +++ b/delete.c @@ -36,7 +36,7 @@ do_delete(time_t backup_id) /* Get complete list of backups */ backup_list = catalog_get_backup_list(0); if (!backup_list) - elog(ERROR, "No backup list found, can't process any more."); + elog(ERROR, "no backup list found, can't process any more"); /* Find backup to be deleted */ for (i = 0; i < parray_num(backup_list); i++) @@ -143,7 +143,8 @@ do_retention_purge(void) time_t days_threshold = time(NULL) - (retention_window * 60 * 60 * 24); XLogRecPtr oldest_lsn = InvalidXLogRecPtr; TimeLineID oldest_tli; - bool keep_next_backup = true; /* Do not delete first full backup */ + bool keep_next_backup = true; /* Do not delete first full backup */ + bool backup_deleted = false; /* At least one backup was deleted */ if (retention_redundancy > 0) elog(LOG, "REDUNDANCY=%u", retention_redundancy); @@ -160,8 +161,7 @@ do_retention_purge(void) backup_list = catalog_get_backup_list(0); if (parray_num(backup_list) == 0) { - elog(INFO, "backup list is empty"); - elog(INFO, "exit"); + elog(INFO, "backup list is empty, purging won't be executed"); return 0; } @@ -207,6 +207,7 @@ do_retention_purge(void) /* Delete backup and update status to DELETED */ pgBackupDeleteFiles(backup); + backup_deleted = true; } /* Purge WAL files */ @@ -216,7 +217,10 @@ do_retention_purge(void) parray_walk(backup_list, pgBackupFree); parray_free(backup_list); - elog(INFO, "purging is finished"); + if (backup_deleted) + elog(INFO, "purging finished"); + else + elog(INFO, "no one backup was deleted by retention policy"); return 0; } diff --git a/pg_probackup.c b/pg_probackup.c index db83d823..11c9a64f 100644 --- a/pg_probackup.c +++ b/pg_probackup.c @@ -16,7 +16,7 @@ #include #include -const char *PROGRAM_VERSION = "1.1.3"; +const char *PROGRAM_VERSION = "1.1.4"; const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup"; const char *PROGRAM_EMAIL = "https://github.com/postgrespro/pg_probackup/issues"; diff --git a/restore.c b/restore.c index 90189771..33f77fdb 100644 --- a/restore.c +++ b/restore.c @@ -212,8 +212,10 @@ base_backup_found: } /* create recovery.conf */ - create_recovery_conf(backup_id, target_time, target_xid, - target_inclusive, base_backup->tli); + dest_backup = (pgBackup *) parray_get(backups, last_diff_index); + if (!dest_backup->stream || (target_time != NULL || target_xid != NULL)) + create_recovery_conf(backup_id, target_time, target_xid, + target_inclusive, base_backup->tli); /* cleanup */ parray_walk(backups, pgBackupFree); diff --git a/tests/expected/option_version.out b/tests/expected/option_version.out index b8e960ea..8e37e6c9 100644 --- a/tests/expected/option_version.out +++ b/tests/expected/option_version.out @@ -1 +1 @@ -pg_probackup 1.1.3 +pg_probackup 1.1.4