2013-01-24 09:35:48 +03:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* delete.c: delete backup files.
|
|
|
|
*
|
2017-03-01 15:50:07 +02:00
|
|
|
* Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
|
|
|
|
* Portions Copyright (c) 2015-2017, Postgres Professional
|
2013-01-24 09:35:48 +03:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2016-11-16 19:34:21 +02:00
|
|
|
#include "pg_probackup.h"
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2016-01-18 09:11:47 +02:00
|
|
|
#include <dirent.h>
|
2017-02-12 22:42:10 +02:00
|
|
|
#include <time.h>
|
2016-01-18 09:11:47 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2013-01-24 09:35:48 +03:00
|
|
|
static int pgBackupDeleteFiles(pgBackup *backup);
|
2017-02-12 22:42:10 +02:00
|
|
|
static void delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli,
|
|
|
|
bool delete_all);
|
2013-01-24 09:35:48 +03:00
|
|
|
|
|
|
|
int
|
2016-10-31 17:19:11 +02:00
|
|
|
do_delete(time_t backup_id)
|
2013-01-24 09:35:48 +03:00
|
|
|
{
|
2016-01-18 09:11:47 +02:00
|
|
|
int i;
|
2016-11-09 16:29:48 +02:00
|
|
|
int b_index;
|
2016-01-18 09:11:47 +02:00
|
|
|
int ret;
|
2016-10-31 17:19:11 +02:00
|
|
|
parray *backup_list;
|
2016-11-22 14:20:39 +02:00
|
|
|
pgBackup *last_backup = NULL;
|
2013-01-24 09:35:48 +03:00
|
|
|
|
|
|
|
/* DATE are always required */
|
2016-10-31 17:19:11 +02:00
|
|
|
if (backup_id == 0)
|
2016-11-16 14:14:50 +02:00
|
|
|
elog(ERROR, "required backup ID not specified");
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2014-01-09 20:37:33 +03:00
|
|
|
/* Lock backup catalog */
|
2017-02-12 22:42:10 +02:00
|
|
|
ret = catalog_lock(false);
|
2013-01-24 09:35:48 +03:00
|
|
|
if (ret == -1)
|
2016-01-19 05:41:30 +02:00
|
|
|
elog(ERROR, "can't lock backup catalog.");
|
2013-01-24 09:35:48 +03:00
|
|
|
else if (ret == 1)
|
2016-01-19 05:41:30 +02:00
|
|
|
elog(ERROR,
|
2017-02-12 22:42:10 +02:00
|
|
|
"another pg_probackup is running, stop delete.");
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2016-01-18 08:24:28 +02:00
|
|
|
/* Get complete list of backups */
|
2016-10-31 17:19:11 +02:00
|
|
|
backup_list = catalog_get_backup_list(0);
|
2014-01-09 20:37:33 +03:00
|
|
|
if (!backup_list)
|
2016-01-19 05:41:30 +02:00
|
|
|
elog(ERROR, "No backup list found, can't process any more.");
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2016-11-09 16:29:48 +02:00
|
|
|
/* Find backup to be deleted */
|
2013-01-24 09:35:48 +03:00
|
|
|
for (i = 0; i < parray_num(backup_list); i++)
|
|
|
|
{
|
2016-11-09 16:29:48 +02:00
|
|
|
last_backup = (pgBackup *) parray_get(backup_list, i);
|
2016-11-22 14:20:39 +02:00
|
|
|
if (last_backup->start_time == backup_id)
|
2016-11-09 16:29:48 +02:00
|
|
|
goto found_backup;
|
|
|
|
}
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2016-11-09 16:29:48 +02:00
|
|
|
elog(ERROR, "no backup found, cannot delete.");
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2016-11-09 16:29:48 +02:00
|
|
|
found_backup:
|
|
|
|
b_index = i;
|
|
|
|
/* check for interrupt */
|
|
|
|
if (interrupted)
|
|
|
|
elog(ERROR, "interrupted during delete backup");
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2016-11-09 16:29:48 +02:00
|
|
|
/* just do it */
|
|
|
|
pgBackupDeleteFiles(last_backup);
|
|
|
|
|
2016-11-22 14:20:39 +02:00
|
|
|
if (last_backup->status == BACKUP_STATUS_ERROR)
|
|
|
|
return 0;
|
|
|
|
|
2016-11-09 16:29:48 +02:00
|
|
|
/* remove all increments after removed backup */
|
|
|
|
for (i = b_index - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
pgBackup *backup = (pgBackup *) parray_get(backup_list, i);
|
|
|
|
if (backup->backup_mode >= BACKUP_MODE_FULL)
|
|
|
|
break;
|
2016-11-22 14:20:39 +02:00
|
|
|
if ((backup->status == BACKUP_STATUS_OK || backup->status == BACKUP_STATUS_CORRUPT) &&
|
|
|
|
(backup->backup_mode == BACKUP_MODE_DIFF_PAGE || backup->backup_mode == BACKUP_MODE_DIFF_PTRACK)
|
2016-11-09 16:29:48 +02:00
|
|
|
)
|
|
|
|
pgBackupDeleteFiles(backup);
|
2013-01-24 09:35:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* release catalog lock */
|
|
|
|
catalog_unlock();
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
parray_walk(backup_list, pgBackupFree);
|
|
|
|
parray_free(backup_list);
|
2016-11-16 16:38:11 +02:00
|
|
|
|
|
|
|
if (delete_wal)
|
|
|
|
do_deletewal(backup_id, false);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-12 22:42:10 +02:00
|
|
|
/*
|
|
|
|
* Delete in archive WAL segments that are not needed anymore. The oldest
|
|
|
|
* segment to be kept is the first segment that the oldest full backup
|
|
|
|
* found around needs to keep.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
do_deletewal(time_t backup_id, bool strict)
|
2016-11-16 16:38:11 +02:00
|
|
|
{
|
2017-02-12 22:42:10 +02:00
|
|
|
size_t i;
|
2016-11-16 16:38:11 +02:00
|
|
|
int ret;
|
|
|
|
parray *backup_list;
|
|
|
|
XLogRecPtr oldest_lsn = InvalidXLogRecPtr;
|
|
|
|
TimeLineID oldest_tli;
|
|
|
|
bool backup_found = false;
|
|
|
|
|
|
|
|
/* Lock backup catalog */
|
2017-02-12 22:42:10 +02:00
|
|
|
ret = catalog_lock(false);
|
2016-11-16 16:38:11 +02:00
|
|
|
if (ret == -1)
|
|
|
|
elog(ERROR, "can't lock backup catalog.");
|
|
|
|
else if (ret == 1)
|
|
|
|
elog(ERROR,
|
2017-02-12 22:42:10 +02:00
|
|
|
"another pg_probackup is running, stop delete.");
|
2016-11-16 16:38:11 +02:00
|
|
|
|
2017-02-12 22:42:10 +02:00
|
|
|
/* Find oldest LSN, used by backups */
|
2016-11-16 16:38:11 +02:00
|
|
|
backup_list = catalog_get_backup_list(0);
|
|
|
|
for (i = 0; i < parray_num(backup_list); i++)
|
2016-11-09 16:29:48 +02:00
|
|
|
{
|
2017-02-12 22:42:10 +02:00
|
|
|
pgBackup *last_backup = (pgBackup *) parray_get(backup_list, i);
|
|
|
|
|
2016-11-16 16:38:11 +02:00
|
|
|
if (last_backup->status == BACKUP_STATUS_OK)
|
2016-11-09 16:29:48 +02:00
|
|
|
{
|
2016-11-16 16:38:11 +02:00
|
|
|
oldest_lsn = last_backup->start_lsn;
|
|
|
|
oldest_tli = last_backup->tli;
|
2017-02-12 22:42:10 +02:00
|
|
|
|
2016-11-16 16:38:11 +02:00
|
|
|
if (strict && backup_id != 0 && backup_id >= last_backup->start_time)
|
2016-11-09 16:29:48 +02:00
|
|
|
{
|
2016-11-16 16:38:11 +02:00
|
|
|
backup_found = true;
|
|
|
|
break;
|
2016-11-09 16:29:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-02-12 22:42:10 +02:00
|
|
|
|
2016-11-16 16:38:11 +02:00
|
|
|
if (strict && backup_id != 0 && backup_found == false)
|
|
|
|
elog(ERROR, "not found backup for deletwal command");
|
2017-02-12 22:42:10 +02:00
|
|
|
|
2016-11-16 16:38:11 +02:00
|
|
|
catalog_unlock();
|
|
|
|
parray_walk(backup_list, pgBackupFree);
|
|
|
|
parray_free(backup_list);
|
2016-11-09 16:29:48 +02:00
|
|
|
|
2017-02-15 17:28:34 +02:00
|
|
|
delete_walfiles(oldest_lsn, oldest_tli, true);
|
2016-01-18 09:11:47 +02:00
|
|
|
|
2013-01-24 09:35:48 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2017-02-12 22:42:10 +02:00
|
|
|
* Remove backups by retention policy. Retention policy is configured by
|
|
|
|
* retention_redundancy and retention_window variables.
|
2013-01-24 09:35:48 +03:00
|
|
|
*/
|
2017-02-12 22:42:10 +02:00
|
|
|
int
|
|
|
|
do_retention_purge(void)
|
2013-01-24 09:35:48 +03:00
|
|
|
{
|
2017-02-12 22:42:10 +02:00
|
|
|
parray *backup_list;
|
|
|
|
uint32 backup_num;
|
|
|
|
size_t i;
|
|
|
|
time_t days_threshold = time(NULL) - (retention_window * 60 * 60 * 24);
|
|
|
|
XLogRecPtr oldest_lsn = InvalidXLogRecPtr;
|
|
|
|
TimeLineID oldest_tli;
|
|
|
|
int ret;
|
2017-02-15 19:44:06 +02:00
|
|
|
bool keep_next_backup = true; /* Do not delete first full backup */
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2017-02-12 22:42:10 +02:00
|
|
|
if (retention_redundancy > 0)
|
|
|
|
elog(LOG, "REDUNDANCY=%u", retention_redundancy);
|
|
|
|
if (retention_window > 0)
|
|
|
|
elog(LOG, "WINDOW=%u", retention_window);
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2017-02-12 22:42:10 +02:00
|
|
|
if (retention_redundancy == 0 && retention_window == 0)
|
|
|
|
elog(ERROR, "retention policy is not set");
|
|
|
|
|
|
|
|
/* Lock backup catalog */
|
|
|
|
ret = catalog_lock(false);
|
|
|
|
if (ret == 1)
|
|
|
|
elog(ERROR,
|
|
|
|
"cannot lock backup catalog, another pg_probackup is running");
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2014-01-09 20:37:33 +03:00
|
|
|
/* Get a complete list of backups. */
|
2016-10-31 17:19:11 +02:00
|
|
|
backup_list = catalog_get_backup_list(0);
|
2017-02-12 22:42:10 +02:00
|
|
|
if (parray_num(backup_list) == 0)
|
|
|
|
{
|
|
|
|
elog(INFO, "backup list is empty");
|
|
|
|
elog(INFO, "exit");
|
|
|
|
catalog_unlock();
|
|
|
|
return 0;
|
|
|
|
}
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2014-01-09 20:37:33 +03:00
|
|
|
/* Find target backups to be deleted */
|
2013-01-24 09:35:48 +03:00
|
|
|
backup_num = 0;
|
|
|
|
for (i = 0; i < parray_num(backup_list); i++)
|
|
|
|
{
|
2014-01-17 16:02:27 +03:00
|
|
|
pgBackup *backup = (pgBackup *) parray_get(backup_list, i);
|
2017-02-12 22:42:10 +02:00
|
|
|
uint32 backup_num_evaluate = backup_num;
|
2014-01-09 20:37:33 +03:00
|
|
|
|
2017-02-15 19:44:06 +02:00
|
|
|
/* Consider only validated and correct backups */
|
|
|
|
if (backup->status != BACKUP_STATUS_OK)
|
|
|
|
continue;
|
|
|
|
|
2013-01-24 09:35:48 +03:00
|
|
|
/*
|
2014-01-09 20:37:33 +03:00
|
|
|
* When a validate full backup was found, we can delete the
|
2014-01-17 16:02:27 +03:00
|
|
|
* backup that is older than it using the number of generations.
|
2013-01-24 09:35:48 +03:00
|
|
|
*/
|
2017-02-12 22:42:10 +02:00
|
|
|
if (backup->backup_mode == BACKUP_MODE_FULL)
|
2013-01-24 09:35:48 +03:00
|
|
|
backup_num++;
|
|
|
|
|
2014-01-09 20:37:33 +03:00
|
|
|
/* Evaluate if this backup is eligible for removal */
|
2017-02-15 19:44:06 +02:00
|
|
|
if (keep_next_backup ||
|
|
|
|
backup_num_evaluate + 1 <= retention_redundancy ||
|
|
|
|
(retention_window > 0 && backup->recovery_time >= days_threshold))
|
2013-01-24 09:35:48 +03:00
|
|
|
{
|
2017-02-12 22:42:10 +02:00
|
|
|
/* Save LSN and Timeline to remove unnecessary WAL segments */
|
|
|
|
oldest_lsn = backup->start_lsn;
|
|
|
|
oldest_tli = backup->tli;
|
2017-02-15 19:44:06 +02:00
|
|
|
|
|
|
|
/* Save parent backup of this incremental backup */
|
|
|
|
if (backup->backup_mode != BACKUP_MODE_FULL)
|
|
|
|
keep_next_backup = true;
|
|
|
|
/*
|
|
|
|
* Previous incremental backup was kept or this is first backup
|
|
|
|
* so do not delete this backup.
|
|
|
|
*/
|
|
|
|
else
|
|
|
|
keep_next_backup = false;
|
|
|
|
|
2013-01-24 09:35:48 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-02-12 22:42:10 +02:00
|
|
|
/* Delete backup and update status to DELETED */
|
2013-01-24 09:35:48 +03:00
|
|
|
pgBackupDeleteFiles(backup);
|
|
|
|
}
|
|
|
|
|
2017-02-12 22:42:10 +02:00
|
|
|
/* Purge WAL files */
|
|
|
|
delete_walfiles(oldest_lsn, oldest_tli, true);
|
|
|
|
|
|
|
|
/* Cleanup */
|
2013-01-24 09:35:48 +03:00
|
|
|
parray_walk(backup_list, pgBackupFree);
|
|
|
|
parray_free(backup_list);
|
2017-02-12 22:42:10 +02:00
|
|
|
|
|
|
|
catalog_unlock();
|
|
|
|
|
|
|
|
elog(INFO, "purging is finished");
|
|
|
|
|
|
|
|
return 0;
|
2013-01-24 09:35:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete backup files of the backup and update the status of the backup to
|
|
|
|
* BACKUP_STATUS_DELETED.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
pgBackupDeleteFiles(pgBackup *backup)
|
|
|
|
{
|
2017-02-12 22:42:10 +02:00
|
|
|
size_t i;
|
|
|
|
char path[MAXPGPATH];
|
|
|
|
char timestamp[20];
|
|
|
|
parray *files;
|
2013-01-24 09:35:48 +03:00
|
|
|
|
|
|
|
/*
|
2016-01-18 08:24:28 +02:00
|
|
|
* If the backup was deleted already, there is nothing to do.
|
2013-01-24 09:35:48 +03:00
|
|
|
*/
|
|
|
|
if (backup->status == BACKUP_STATUS_DELETED)
|
|
|
|
return 0;
|
|
|
|
|
2017-02-16 18:44:16 +02:00
|
|
|
time2iso(timestamp, lengthof(timestamp), backup->recovery_time);
|
2013-01-24 09:35:48 +03:00
|
|
|
|
2016-11-09 16:29:48 +02:00
|
|
|
elog(INFO, "delete: %s %s", base36enc(backup->start_time), timestamp);
|
|
|
|
|
2013-01-24 09:35:48 +03:00
|
|
|
/*
|
2016-01-18 08:24:28 +02:00
|
|
|
* Update STATUS to BACKUP_STATUS_DELETING in preparation for the case which
|
2013-01-24 09:35:48 +03:00
|
|
|
* the error occurs before deleting all backup files.
|
|
|
|
*/
|
|
|
|
if (!check)
|
|
|
|
{
|
|
|
|
backup->status = BACKUP_STATUS_DELETING;
|
|
|
|
pgBackupWriteIni(backup);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* list files to be deleted */
|
|
|
|
files = parray_new();
|
2016-11-09 16:29:48 +02:00
|
|
|
pgBackupGetPath(backup, path, lengthof(path), NULL);
|
2017-02-13 13:11:00 +02:00
|
|
|
dir_list_file(files, path, false, true, true);
|
2013-01-24 09:35:48 +03:00
|
|
|
|
|
|
|
/* delete leaf node first */
|
|
|
|
parray_qsort(files, pgFileComparePathDesc);
|
|
|
|
for (i = 0; i < parray_num(files); i++)
|
|
|
|
{
|
2017-02-16 16:23:43 +02:00
|
|
|
pgFile *file = (pgFile *) parray_get(files, i);
|
2013-01-24 09:35:48 +03:00
|
|
|
|
|
|
|
/* print progress */
|
2017-02-12 22:42:10 +02:00
|
|
|
elog(LOG, "delete file(%zd/%lu) \"%s\"", i + 1,
|
2013-01-24 09:35:48 +03:00
|
|
|
(unsigned long) parray_num(files), file->path);
|
|
|
|
|
|
|
|
/* skip actual deletion in check mode */
|
|
|
|
if (!check)
|
|
|
|
{
|
|
|
|
if (remove(file->path))
|
|
|
|
{
|
2016-01-14 09:36:39 +02:00
|
|
|
elog(WARNING, "can't remove \"%s\": %s", file->path,
|
2013-01-24 09:35:48 +03:00
|
|
|
strerror(errno));
|
|
|
|
parray_walk(files, pgFileFree);
|
|
|
|
parray_free(files);
|
2017-02-12 22:42:10 +02:00
|
|
|
|
2013-01-24 09:35:48 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
parray_walk(files, pgFileFree);
|
|
|
|
parray_free(files);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-02-12 22:42:10 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete WAL segments up to oldest_lsn.
|
|
|
|
*
|
|
|
|
* If oldest_lsn is invalid function exists. But if delete_all is true then
|
|
|
|
* WAL segements will be deleted anyway.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli, bool delete_all)
|
|
|
|
{
|
|
|
|
XLogSegNo targetSegNo;
|
|
|
|
char oldestSegmentNeeded[MAXFNAMELEN];
|
|
|
|
DIR *arcdir;
|
|
|
|
struct dirent *arcde;
|
|
|
|
char wal_file[MAXPGPATH];
|
|
|
|
char max_wal_file[MAXPGPATH];
|
|
|
|
char min_wal_file[MAXPGPATH];
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (XLogRecPtrIsInvalid(oldest_lsn) && !delete_all)
|
|
|
|
return;
|
|
|
|
|
|
|
|
max_wal_file[0] = '\0';
|
|
|
|
min_wal_file[0] = '\0';
|
|
|
|
|
|
|
|
if (!XLogRecPtrIsInvalid(oldest_lsn))
|
|
|
|
{
|
|
|
|
XLByteToSeg(oldest_lsn, targetSegNo);
|
|
|
|
XLogFileName(oldestSegmentNeeded, oldest_tli, targetSegNo);
|
|
|
|
|
|
|
|
elog(LOG, "removing WAL segments older than %s", oldestSegmentNeeded);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elog(LOG, "removing all WAL segments");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now it is time to do the actual work and to remove all the segments
|
|
|
|
* not needed anymore.
|
|
|
|
*/
|
|
|
|
if ((arcdir = opendir(arclog_path)) != NULL)
|
|
|
|
{
|
|
|
|
while (errno = 0, (arcde = readdir(arcdir)) != NULL)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We ignore the timeline part of the XLOG segment identifiers in
|
|
|
|
* deciding whether a segment is still needed. This ensures that
|
|
|
|
* we won't prematurely remove a segment from a parent timeline.
|
|
|
|
* We could probably be a little more proactive about removing
|
|
|
|
* segments of non-parent timelines, but that would be a whole lot
|
|
|
|
* more complicated.
|
|
|
|
*
|
|
|
|
* We use the alphanumeric sorting property of the filenames to
|
|
|
|
* decide which ones are earlier than the exclusiveCleanupFileName
|
|
|
|
* file. Note that this means files are not removed in the order
|
|
|
|
* they were originally written, in case this worries you.
|
|
|
|
*/
|
|
|
|
if (IsXLogFileName(arcde->d_name) ||
|
2017-02-15 17:28:34 +02:00
|
|
|
IsPartialXLogFileName(arcde->d_name) ||
|
|
|
|
IsBackupHistoryFileName(arcde->d_name))
|
2017-02-12 22:42:10 +02:00
|
|
|
{
|
|
|
|
if (XLogRecPtrIsInvalid(oldest_lsn) ||
|
2017-02-15 17:28:34 +02:00
|
|
|
strncmp(arcde->d_name + 8, oldestSegmentNeeded + 8, 16) < 0)
|
2017-02-12 22:42:10 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Use the original file name again now, including any
|
|
|
|
* extension that might have been chopped off before testing
|
|
|
|
* the sequence.
|
|
|
|
*/
|
|
|
|
snprintf(wal_file, MAXPGPATH, "%s/%s",
|
|
|
|
arclog_path, arcde->d_name);
|
|
|
|
|
|
|
|
rc = unlink(wal_file);
|
|
|
|
if (rc != 0)
|
|
|
|
{
|
|
|
|
elog(WARNING, "could not remove file \"%s\": %s",
|
|
|
|
wal_file, strerror(errno));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (verbose)
|
|
|
|
elog(LOG, "removed WAL segment \"%s\"", wal_file);
|
|
|
|
|
|
|
|
if (max_wal_file[0] == '\0' ||
|
|
|
|
strcmp(max_wal_file + 8, arcde->d_name + 8) < 0)
|
|
|
|
strcpy(max_wal_file, arcde->d_name);
|
|
|
|
|
|
|
|
if (min_wal_file[0] == '\0' ||
|
|
|
|
strcmp(min_wal_file + 8, arcde->d_name + 8) > 0)
|
|
|
|
strcpy(min_wal_file, arcde->d_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!verbose && min_wal_file[0] != '\0')
|
|
|
|
elog(INFO, "removed min WAL segment \"%s\"", min_wal_file);
|
|
|
|
if (!verbose && max_wal_file[0] != '\0')
|
|
|
|
elog(INFO, "removed max WAL segment \"%s\"", max_wal_file);
|
|
|
|
|
|
|
|
if (errno)
|
|
|
|
elog(WARNING, "could not read archive location \"%s\": %s",
|
|
|
|
arclog_path, strerror(errno));
|
|
|
|
if (closedir(arcdir))
|
|
|
|
elog(WARNING, "could not close archive location \"%s\": %s",
|
|
|
|
arclog_path, strerror(errno));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elog(WARNING, "could not open archive location \"%s\": %s",
|
|
|
|
arclog_path, strerror(errno));
|
|
|
|
}
|