You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-07-16 07:14:15 +02:00
Remove server backup feature
In order to keep only the core of pg_rman for incremental/differential backup, this looks necessary and makes the code more simple. Including server log files in a backup could be subject to discussion as well, as for example a Postgres base backup does not include them, just because in this case server instance is not aware of the log files.
This commit is contained in:
107
backup.c
107
backup.c
@ -1,6 +1,6 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* backup.c: backup DB cluster, archived WAL, serverlog.
|
* backup.c: backup DB cluster, archived WAL
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
|
* Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
|
||||||
*
|
*
|
||||||
@ -42,7 +42,6 @@ static void backup_files(const char *from_root, const char *to_root,
|
|||||||
parray *files, parray *prev_files, const XLogRecPtr *lsn, bool compress, const char *prefix);
|
parray *files, parray *prev_files, const XLogRecPtr *lsn, bool compress, const char *prefix);
|
||||||
static parray *do_backup_database(parray *backup_list, pgBackupOption bkupopt);
|
static parray *do_backup_database(parray *backup_list, pgBackupOption bkupopt);
|
||||||
static parray *do_backup_arclog(parray *backup_list);
|
static parray *do_backup_arclog(parray *backup_list);
|
||||||
static parray *do_backup_srvlog(parray *backup_list);
|
|
||||||
static void confirm_block_size(const char *name, int blcksz);
|
static void confirm_block_size(const char *name, int blcksz);
|
||||||
static void pg_start_backup(const char *label, bool smooth, pgBackup *backup);
|
static void pg_start_backup(const char *label, bool smooth, pgBackup *backup);
|
||||||
static void pg_stop_backup(pgBackup *backup);
|
static void pg_stop_backup(pgBackup *backup);
|
||||||
@ -567,100 +566,17 @@ do_backup_arclog(parray *backup_list)
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Take a backup of serverlog.
|
|
||||||
*/
|
|
||||||
static parray *
|
|
||||||
do_backup_srvlog(parray *backup_list)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
parray *files;
|
|
||||||
parray *prev_files = NULL; /* file list of previous database backup */
|
|
||||||
char path[MAXPGPATH];
|
|
||||||
char prev_file_txt[MAXPGPATH];
|
|
||||||
pgBackup *prev_backup;
|
|
||||||
int64 srvlog_write_bytes = 0;
|
|
||||||
|
|
||||||
if (!current.with_serverlog)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Block backup operations on a standby */
|
|
||||||
if (pg_is_standby())
|
|
||||||
elog(ERROR_SYSTEM, _("Backup cannot run on a standby."));
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
printf(_("========================================\n"));
|
|
||||||
printf(_("serverlog backup start\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize size summary */
|
|
||||||
current.srvlog_bytes = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To take incremental backup, the file list of the last completed database
|
|
||||||
* backup is needed.
|
|
||||||
*/
|
|
||||||
prev_backup = catalog_get_last_srvlog_backup(backup_list,
|
|
||||||
get_current_timeline());
|
|
||||||
if (verbose && prev_backup == NULL)
|
|
||||||
printf(_("no previous full backup, performing a full backup instead\n"));
|
|
||||||
|
|
||||||
if (prev_backup)
|
|
||||||
{
|
|
||||||
pgBackupGetPath(prev_backup, prev_file_txt, lengthof(prev_file_txt),
|
|
||||||
SRVLOG_FILE_LIST);
|
|
||||||
prev_files = dir_read_file_list(srvlog_path, prev_file_txt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* list files with the logical path. omit SRVLOG_PATH */
|
|
||||||
files = parray_new();
|
|
||||||
dir_list_file(files, srvlog_path, NULL, true, false);
|
|
||||||
|
|
||||||
pgBackupGetPath(¤t, path, lengthof(path), SRVLOG_DIR);
|
|
||||||
backup_files(srvlog_path, path, files, prev_files, NULL, false, NULL);
|
|
||||||
|
|
||||||
/* create file list */
|
|
||||||
create_file_list(files, arclog_path, SRVLOG_FILE_LIST, NULL, false);
|
|
||||||
|
|
||||||
/* print summary of size of backup mode files */
|
|
||||||
for (i = 0; i < parray_num(files); i++)
|
|
||||||
{
|
|
||||||
pgFile *file = (pgFile *) parray_get(files, i);
|
|
||||||
if (!S_ISREG(file->mode))
|
|
||||||
continue;
|
|
||||||
current.srvlog_bytes += file->read_size;
|
|
||||||
if (file->write_size != BYTES_INVALID)
|
|
||||||
{
|
|
||||||
current.backup_bytes += file->write_size;
|
|
||||||
srvlog_write_bytes += file->write_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
printf(_("serverlog backup completed(read: " INT64_FORMAT " write: " INT64_FORMAT ")\n"),
|
|
||||||
current.srvlog_bytes, srvlog_write_bytes);
|
|
||||||
printf(_("========================================\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
do_backup(pgBackupOption bkupopt)
|
do_backup(pgBackupOption bkupopt)
|
||||||
{
|
{
|
||||||
parray *backup_list;
|
parray *backup_list;
|
||||||
parray *files_database;
|
parray *files_database;
|
||||||
parray *files_arclog;
|
parray *files_arclog;
|
||||||
parray *files_srvlog;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* repack the necesary options */
|
/* repack the necesary options */
|
||||||
int keep_arclog_files = bkupopt.keep_arclog_files;
|
int keep_arclog_files = bkupopt.keep_arclog_files;
|
||||||
int keep_arclog_days = bkupopt.keep_arclog_days;
|
int keep_arclog_days = bkupopt.keep_arclog_days;
|
||||||
int keep_srvlog_files = bkupopt.keep_srvlog_files;
|
|
||||||
int keep_srvlog_days = bkupopt.keep_srvlog_days;
|
|
||||||
int keep_data_generations = bkupopt.keep_data_generations;
|
int keep_data_generations = bkupopt.keep_data_generations;
|
||||||
int keep_data_days = bkupopt.keep_data_days;
|
int keep_data_days = bkupopt.keep_data_days;
|
||||||
|
|
||||||
@ -680,11 +596,6 @@ do_backup(pgBackupOption bkupopt)
|
|||||||
_("Required parameter not specified: ARCLOG_PATH "
|
_("Required parameter not specified: ARCLOG_PATH "
|
||||||
"(-A, --arclog-path)"));
|
"(-A, --arclog-path)"));
|
||||||
|
|
||||||
/* SRVLOG_PATH is required only when backup serverlog */
|
|
||||||
if (current.with_serverlog && srvlog_path == NULL)
|
|
||||||
elog(ERROR_ARGS, _("required parameter not specified: SRVLOG_PATH "
|
|
||||||
"(-S, --srvlog-path)"));
|
|
||||||
|
|
||||||
#ifndef HAVE_LIBZ
|
#ifndef HAVE_LIBZ
|
||||||
if (current.compress_data)
|
if (current.compress_data)
|
||||||
{
|
{
|
||||||
@ -727,7 +638,6 @@ do_backup(pgBackupOption bkupopt)
|
|||||||
current.end_time = (time_t) 0;
|
current.end_time = (time_t) 0;
|
||||||
current.data_bytes = BYTES_INVALID;
|
current.data_bytes = BYTES_INVALID;
|
||||||
current.arclog_bytes = BYTES_INVALID;
|
current.arclog_bytes = BYTES_INVALID;
|
||||||
current.srvlog_bytes = BYTES_INVALID;
|
|
||||||
current.backup_bytes = 0;
|
current.backup_bytes = 0;
|
||||||
current.block_size = BLCKSZ;
|
current.block_size = BLCKSZ;
|
||||||
current.wal_block_size = XLOG_BLCKSZ;
|
current.wal_block_size = XLOG_BLCKSZ;
|
||||||
@ -757,9 +667,6 @@ do_backup(pgBackupOption bkupopt)
|
|||||||
|
|
||||||
/* backup archived WAL */
|
/* backup archived WAL */
|
||||||
files_arclog = do_backup_arclog(backup_list);
|
files_arclog = do_backup_arclog(backup_list);
|
||||||
|
|
||||||
/* backup serverlog */
|
|
||||||
files_srvlog = do_backup_srvlog(backup_list);
|
|
||||||
pgut_atexit_pop(backup_cleanup, NULL);
|
pgut_atexit_pop(backup_cleanup, NULL);
|
||||||
|
|
||||||
/* update backup status to DONE */
|
/* update backup status to DONE */
|
||||||
@ -781,10 +688,6 @@ do_backup(pgBackupOption bkupopt)
|
|||||||
current.backup_mode == BACKUP_MODE_INCREMENTAL)
|
current.backup_mode == BACKUP_MODE_INCREMENTAL)
|
||||||
total_read += current.arclog_bytes;
|
total_read += current.arclog_bytes;
|
||||||
|
|
||||||
/* Server logs */
|
|
||||||
if (current.with_serverlog)
|
|
||||||
total_read += current.srvlog_bytes;
|
|
||||||
|
|
||||||
if (total_read == 0)
|
if (total_read == 0)
|
||||||
printf(_("nothing to backup\n"));
|
printf(_("nothing to backup\n"));
|
||||||
else
|
else
|
||||||
@ -795,13 +698,10 @@ do_backup(pgBackupOption bkupopt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete old files (archived WAL and serverlog) after update of status.
|
* Delete old files (archived WAL) after update of status.
|
||||||
*/
|
*/
|
||||||
delete_old_files(arclog_path, files_arclog, keep_arclog_files,
|
delete_old_files(arclog_path, files_arclog, keep_arclog_files,
|
||||||
keep_arclog_days, true);
|
keep_arclog_days, true);
|
||||||
if (current.with_serverlog)
|
|
||||||
delete_old_files(srvlog_path, files_srvlog, keep_srvlog_files,
|
|
||||||
keep_srvlog_days, false);
|
|
||||||
|
|
||||||
/* Delete old backup files after all backup operation. */
|
/* Delete old backup files after all backup operation. */
|
||||||
pgBackupDelete(keep_data_generations, keep_data_days);
|
pgBackupDelete(keep_data_generations, keep_data_days);
|
||||||
@ -813,9 +713,6 @@ do_backup(pgBackupOption bkupopt)
|
|||||||
if (files_arclog)
|
if (files_arclog)
|
||||||
parray_walk(files_arclog, pgFileFree);
|
parray_walk(files_arclog, pgFileFree);
|
||||||
parray_free(files_arclog);
|
parray_free(files_arclog);
|
||||||
if (files_srvlog)
|
|
||||||
parray_walk(files_srvlog, pgFileFree);
|
|
||||||
parray_free(files_srvlog);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this backup is full backup, delete backup of online WAL.
|
* If this backup is full backup, delete backup of online WAL.
|
||||||
|
39
catalog.c
39
catalog.c
@ -160,7 +160,7 @@ catalog_get_backup_list(const pgBackupRange *range)
|
|||||||
if (!IsDir(backup_path, date_dir, date_ent) || date_ent->d_name[0] == '.')
|
if (!IsDir(backup_path, date_dir, date_ent) || date_ent->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* skip online WAL & serverlog backup directory */
|
/* skip online WAL backup directory */
|
||||||
if (strcmp(date_ent->d_name, RESTORE_WORK_DIR) == 0)
|
if (strcmp(date_ent->d_name, RESTORE_WORK_DIR) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -292,38 +292,13 @@ catalog_get_last_arclog_backup(parray *backup_list, TimeLineID tli)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Find the last completed serverlog backup from the backup list
|
|
||||||
* on current timeline.
|
|
||||||
*/
|
|
||||||
pgBackup *
|
|
||||||
catalog_get_last_srvlog_backup(parray *backup_list, TimeLineID tli)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
pgBackup *backup = NULL;
|
|
||||||
|
|
||||||
/* backup_list is sorted in order of descending ID */
|
|
||||||
for (i = 0; i < parray_num(backup_list); i++)
|
|
||||||
{
|
|
||||||
backup = (pgBackup *) parray_get(backup_list, i);
|
|
||||||
|
|
||||||
/* we need completed serverlog backup */
|
|
||||||
if (backup->status == BACKUP_STATUS_OK &&
|
|
||||||
backup->with_serverlog &&
|
|
||||||
backup->tli == tli)
|
|
||||||
return backup;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create backup directory in $BACKUP_PATH */
|
/* create backup directory in $BACKUP_PATH */
|
||||||
int
|
int
|
||||||
pgBackupCreateDir(pgBackup *backup)
|
pgBackupCreateDir(pgBackup *backup)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char path[MAXPGPATH];
|
char path[MAXPGPATH];
|
||||||
char *subdirs[] = { DATABASE_DIR, ARCLOG_DIR, SRVLOG_DIR, NULL };
|
char *subdirs[] = { DATABASE_DIR, ARCLOG_DIR, NULL };
|
||||||
|
|
||||||
pgBackupGetPath(backup, path, lengthof(path), NULL);
|
pgBackupGetPath(backup, path, lengthof(path), NULL);
|
||||||
dir_create_dir(path, DIR_PERMISSION);
|
dir_create_dir(path, DIR_PERMISSION);
|
||||||
@ -349,7 +324,6 @@ pgBackupWriteConfigSection(FILE *out, pgBackup *backup)
|
|||||||
fprintf(out, "# configuration\n");
|
fprintf(out, "# configuration\n");
|
||||||
|
|
||||||
fprintf(out, "BACKUP_MODE=%s\n", modes[backup->backup_mode]);
|
fprintf(out, "BACKUP_MODE=%s\n", modes[backup->backup_mode]);
|
||||||
fprintf(out, "WITH_SERVERLOG=%s\n", BOOL_TO_STR(backup->with_serverlog));
|
|
||||||
fprintf(out, "COMPRESS_DATA=%s\n", BOOL_TO_STR(backup->compress_data));
|
fprintf(out, "COMPRESS_DATA=%s\n", BOOL_TO_STR(backup->compress_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,9 +364,6 @@ pgBackupWriteResultSection(FILE *out, pgBackup *backup)
|
|||||||
if (backup->arclog_bytes != BYTES_INVALID)
|
if (backup->arclog_bytes != BYTES_INVALID)
|
||||||
fprintf(out, "ARCLOG_BYTES=" INT64_FORMAT "\n",
|
fprintf(out, "ARCLOG_BYTES=" INT64_FORMAT "\n",
|
||||||
backup->arclog_bytes);
|
backup->arclog_bytes);
|
||||||
if (backup->srvlog_bytes != BYTES_INVALID)
|
|
||||||
fprintf(out, "SRVLOG_BYTES=" INT64_FORMAT "\n",
|
|
||||||
backup->srvlog_bytes);
|
|
||||||
if (backup->backup_bytes != BYTES_INVALID)
|
if (backup->backup_bytes != BYTES_INVALID)
|
||||||
fprintf(out, "BACKUP_BYTES=" INT64_FORMAT "\n",
|
fprintf(out, "BACKUP_BYTES=" INT64_FORMAT "\n",
|
||||||
backup->backup_bytes);
|
backup->backup_bytes);
|
||||||
@ -443,7 +414,6 @@ catalog_read_ini(const char *path)
|
|||||||
pgut_option options[] =
|
pgut_option options[] =
|
||||||
{
|
{
|
||||||
{ 's', 0, "backup-mode" , NULL, SOURCE_ENV },
|
{ 's', 0, "backup-mode" , NULL, SOURCE_ENV },
|
||||||
{ 'b', 0, "with-serverlog" , NULL, SOURCE_ENV },
|
|
||||||
{ 'b', 0, "compress-data" , NULL, SOURCE_ENV },
|
{ 'b', 0, "compress-data" , NULL, SOURCE_ENV },
|
||||||
{ 'u', 0, "timelineid" , NULL, SOURCE_ENV },
|
{ 'u', 0, "timelineid" , NULL, SOURCE_ENV },
|
||||||
{ 's', 0, "start-lsn" , NULL, SOURCE_ENV },
|
{ 's', 0, "start-lsn" , NULL, SOURCE_ENV },
|
||||||
@ -454,7 +424,6 @@ catalog_read_ini(const char *path)
|
|||||||
{ 't', 0, "recovery-time" , NULL, SOURCE_ENV },
|
{ 't', 0, "recovery-time" , NULL, SOURCE_ENV },
|
||||||
{ 'I', 0, "data-bytes" , NULL, SOURCE_ENV },
|
{ 'I', 0, "data-bytes" , NULL, SOURCE_ENV },
|
||||||
{ 'I', 0, "arclog-bytes" , NULL, SOURCE_ENV },
|
{ 'I', 0, "arclog-bytes" , NULL, SOURCE_ENV },
|
||||||
{ 'I', 0, "srvlog-bytes" , NULL, SOURCE_ENV },
|
|
||||||
{ 'I', 0, "backup-bytes" , NULL, SOURCE_ENV },
|
{ 'I', 0, "backup-bytes" , NULL, SOURCE_ENV },
|
||||||
{ 'u', 0, "block-size" , NULL, SOURCE_ENV },
|
{ 'u', 0, "block-size" , NULL, SOURCE_ENV },
|
||||||
{ 'u', 0, "xlog-block-size" , NULL, SOURCE_ENV },
|
{ 'u', 0, "xlog-block-size" , NULL, SOURCE_ENV },
|
||||||
@ -471,7 +440,6 @@ catalog_read_ini(const char *path)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
options[i++].var = &backup_mode;
|
options[i++].var = &backup_mode;
|
||||||
options[i++].var = &backup->with_serverlog;
|
|
||||||
options[i++].var = &backup->compress_data;
|
options[i++].var = &backup->compress_data;
|
||||||
options[i++].var = &backup->tli;
|
options[i++].var = &backup->tli;
|
||||||
options[i++].var = &start_lsn;
|
options[i++].var = &start_lsn;
|
||||||
@ -482,7 +450,6 @@ catalog_read_ini(const char *path)
|
|||||||
options[i++].var = &backup->recovery_time;
|
options[i++].var = &backup->recovery_time;
|
||||||
options[i++].var = &backup->data_bytes;
|
options[i++].var = &backup->data_bytes;
|
||||||
options[i++].var = &backup->arclog_bytes;
|
options[i++].var = &backup->arclog_bytes;
|
||||||
options[i++].var = &backup->srvlog_bytes;
|
|
||||||
options[i++].var = &backup->backup_bytes;
|
options[i++].var = &backup->backup_bytes;
|
||||||
options[i++].var = &backup->block_size;
|
options[i++].var = &backup->block_size;
|
||||||
options[i++].var = &backup->wal_block_size;
|
options[i++].var = &backup->wal_block_size;
|
||||||
@ -620,7 +587,6 @@ void
|
|||||||
catalog_init_config(pgBackup *backup)
|
catalog_init_config(pgBackup *backup)
|
||||||
{
|
{
|
||||||
backup->backup_mode = BACKUP_MODE_INVALID;
|
backup->backup_mode = BACKUP_MODE_INVALID;
|
||||||
backup->with_serverlog = false;
|
|
||||||
backup->compress_data = false;
|
backup->compress_data = false;
|
||||||
backup->status = BACKUP_STATUS_INVALID;
|
backup->status = BACKUP_STATUS_INVALID;
|
||||||
backup->tli = 0;
|
backup->tli = 0;
|
||||||
@ -632,6 +598,5 @@ catalog_init_config(pgBackup *backup)
|
|||||||
backup->recovery_time = (time_t) 0;
|
backup->recovery_time = (time_t) 0;
|
||||||
backup->data_bytes = BYTES_INVALID;
|
backup->data_bytes = BYTES_INVALID;
|
||||||
backup->arclog_bytes = BYTES_INVALID;
|
backup->arclog_bytes = BYTES_INVALID;
|
||||||
backup->srvlog_bytes = BYTES_INVALID;
|
|
||||||
backup->backup_bytes = BYTES_INVALID;
|
backup->backup_bytes = BYTES_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# configuration
|
# configuration
|
||||||
BACKUP_MODE=FULL
|
BACKUP_MODE=FULL
|
||||||
WITH_SERVERLOG=NO
|
|
||||||
COMPRESS_DATA=NO
|
COMPRESS_DATA=NO
|
||||||
# result
|
# result
|
||||||
TIMELINEID=1
|
TIMELINEID=1
|
||||||
@ -10,7 +9,6 @@ START_TIME='2009-05-31 17:05:53'
|
|||||||
END_TIME='2009-05-31 17:09:13'
|
END_TIME='2009-05-31 17:09:13'
|
||||||
DATA_BYTES=1242102558
|
DATA_BYTES=1242102558
|
||||||
ARCLOG_BYTES=9223372036854775807
|
ARCLOG_BYTES=9223372036854775807
|
||||||
SRVLOG_BYTES=-1
|
|
||||||
BACKUP_BYTES=242102558
|
BACKUP_BYTES=242102558
|
||||||
BLOCK_SIZE=8192
|
BLOCK_SIZE=8192
|
||||||
XLOG_BLOCK_SIZE=8192
|
XLOG_BLOCK_SIZE=8192
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# configuration
|
# configuration
|
||||||
BACKUP_MODE=INCREMENTAL
|
BACKUP_MODE=INCREMENTAL
|
||||||
WITH_SERVERLOG=NO
|
|
||||||
COMPRESS_DATA=NO
|
COMPRESS_DATA=NO
|
||||||
# result
|
# result
|
||||||
TIMELINEID=1
|
TIMELINEID=1
|
||||||
@ -10,7 +9,6 @@ START_TIME='2009-06-01 17:05:53'
|
|||||||
END_TIME='2009-06-01 17:09:13'
|
END_TIME='2009-06-01 17:09:13'
|
||||||
DATA_BYTES=9223372036854775807
|
DATA_BYTES=9223372036854775807
|
||||||
ARCLOG_BYTES=16777216
|
ARCLOG_BYTES=16777216
|
||||||
SRVLOG_BYTES=-1
|
|
||||||
BACKUP_BYTES=162372983
|
BACKUP_BYTES=162372983
|
||||||
BLOCK_SIZE=8192
|
BLOCK_SIZE=8192
|
||||||
XLOG_BLOCK_SIZE=8192
|
XLOG_BLOCK_SIZE=8192
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# configuration
|
# configuration
|
||||||
BACKUP_MODE=ARCHIVE
|
BACKUP_MODE=ARCHIVE
|
||||||
WITH_SERVERLOG=YES
|
|
||||||
COMPRESS_DATA=NO
|
COMPRESS_DATA=NO
|
||||||
# result
|
# result
|
||||||
TIMELINEID=1
|
TIMELINEID=1
|
||||||
@ -10,7 +9,6 @@ START_TIME='2009-06-02 17:05:03'
|
|||||||
END_TIME='2009-06-02 17:05:03'
|
END_TIME='2009-06-02 17:05:03'
|
||||||
DATA_BYTES=-1
|
DATA_BYTES=-1
|
||||||
ARCLOG_BYTES=-1
|
ARCLOG_BYTES=-1
|
||||||
SRVLOG_BYTES=4335423
|
|
||||||
BACKUP_BYTES=162372983
|
BACKUP_BYTES=162372983
|
||||||
BLOCK_SIZE=8192
|
BLOCK_SIZE=8192
|
||||||
XLOG_BLOCK_SIZE=8192
|
XLOG_BLOCK_SIZE=8192
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# configuration
|
# configuration
|
||||||
BACKUP_MODE=FULL
|
BACKUP_MODE=FULL
|
||||||
WITH_SERVERLOG=YES
|
|
||||||
COMPRESS_DATA=NO
|
COMPRESS_DATA=NO
|
||||||
# result
|
# result
|
||||||
TIMELINEID=1
|
TIMELINEID=1
|
||||||
@ -10,7 +9,6 @@ START_TIME='2009-06-03 17:05:53'
|
|||||||
END_TIME='2009-06-03 17:05:53'
|
END_TIME='2009-06-03 17:05:53'
|
||||||
DATA_BYTES=-1
|
DATA_BYTES=-1
|
||||||
ARCLOG_BYTES=-1
|
ARCLOG_BYTES=-1
|
||||||
SRVLOG_BYTES=-1
|
|
||||||
BACKUP_BYTES=-1
|
BACKUP_BYTES=-1
|
||||||
BLOCK_SIZE=8192
|
BLOCK_SIZE=8192
|
||||||
XLOG_BLOCK_SIZE=8192
|
XLOG_BLOCK_SIZE=8192
|
||||||
|
2
delete.c
2
delete.c
@ -199,8 +199,6 @@ pgBackupDeleteFiles(pgBackup *backup)
|
|||||||
dir_list_file(files, path, NULL, true, true);
|
dir_list_file(files, path, NULL, true, true);
|
||||||
pgBackupGetPath(backup, path, lengthof(path), ARCLOG_DIR);
|
pgBackupGetPath(backup, path, lengthof(path), ARCLOG_DIR);
|
||||||
dir_list_file(files, path, NULL, true, true);
|
dir_list_file(files, path, NULL, true, true);
|
||||||
pgBackupGetPath(backup, path, lengthof(path), SRVLOG_DIR);
|
|
||||||
dir_list_file(files, path, NULL, true, true);
|
|
||||||
|
|
||||||
/* delete leaf node first */
|
/* delete leaf node first */
|
||||||
parray_qsort(files, pgFileComparePathDesc);
|
parray_qsort(files, pgFileComparePathDesc);
|
||||||
|
1
dir.c
1
dir.c
@ -25,7 +25,6 @@ const char *pgdata_exclude[] =
|
|||||||
"pg_stat_tmp",
|
"pg_stat_tmp",
|
||||||
"pgsql_tmp",
|
"pgsql_tmp",
|
||||||
NULL, /* arclog_path will be set later */
|
NULL, /* arclog_path will be set later */
|
||||||
NULL, /* srvlog_path will be set later */
|
|
||||||
NULL, /* 'pg_tblspc' will be set later */
|
NULL, /* 'pg_tblspc' will be set later */
|
||||||
NULL, /* sentinel */
|
NULL, /* sentinel */
|
||||||
};
|
};
|
||||||
|
@ -21,8 +21,8 @@ files.
|
|||||||
== DESCRIPTION ==
|
== DESCRIPTION ==
|
||||||
|
|
||||||
pg_rman is a utility program to backup and restore PostgreSQL database.
|
pg_rman is a utility program to backup and restore PostgreSQL database.
|
||||||
It takes a physical online backup of whole database cluster, archive
|
It takes a physical online backup of whole database cluster and archive
|
||||||
WALs, and server logs.
|
WALs.
|
||||||
|
|
||||||
It proposes the following features:
|
It proposes the following features:
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ specify it in PGDATA environmental variable or -D/--pgdata option.
|
|||||||
|
|
||||||
=== BACKUP ===
|
=== BACKUP ===
|
||||||
|
|
||||||
Backup target can be one of the following types also serverlogs can be added):
|
Backup target can be one of the following types:
|
||||||
|
|
||||||
- Full backup, backup a whole database cluster.
|
- Full backup, backup a whole database cluster.
|
||||||
- Incremental backup, backup only files or pages modified after the last
|
- Incremental backup, backup only files or pages modified after the last
|
||||||
@ -107,22 +107,19 @@ write default configuration into ${BACKUP_PATH}/pg_rman.ini.
|
|||||||
|
|
||||||
$ cat $BACKUP_PATH/pg_rman.ini
|
$ cat $BACKUP_PATH/pg_rman.ini
|
||||||
ARCLOG_PATH = /home/postgres/arclog
|
ARCLOG_PATH = /home/postgres/arclog
|
||||||
SRVLOG_PATH = /home/postgres/pgdata/pg_log
|
|
||||||
BACKUP_MODE = F
|
BACKUP_MODE = F
|
||||||
COMPRESS_DATA = YES
|
COMPRESS_DATA = YES
|
||||||
KEEP_ARCLOG_FILES = 10
|
KEEP_ARCLOG_FILES = 10
|
||||||
KEEP_ARCLOG_DAYS = 10
|
KEEP_ARCLOG_DAYS = 10
|
||||||
KEEP_DATA_GENERATIONS = 3
|
KEEP_DATA_GENERATIONS = 3
|
||||||
KEEP_DATA_DAYS = 120
|
KEEP_DATA_DAYS = 120
|
||||||
KEEP_SRVLOG_FILES = 10
|
|
||||||
KEEP_SRVLOG_DAYS = 10
|
|
||||||
|
|
||||||
=== TAKE A BACKUP ===
|
=== TAKE A BACKUP ===
|
||||||
|
|
||||||
This example takes a full backup of the whole database with server logs.
|
This example takes a full backup of the whole database. Then, it validates
|
||||||
Then, it validates all unvalidated backups.
|
all unvalidated backups.
|
||||||
|
|
||||||
$ pg_rman backup --backup-mode=full --with-serverlog
|
$ pg_rman backup --backup-mode=full
|
||||||
$ pg_rman validate
|
$ pg_rman validate
|
||||||
|
|
||||||
=== RESTORE FROM A BACKUP ===
|
=== RESTORE FROM A BACKUP ===
|
||||||
@ -168,7 +165,6 @@ When a date is specified, more details about a backup is retrieved:
|
|||||||
$ pg_rman show '2011-11-27 19:15:45'
|
$ pg_rman show '2011-11-27 19:15:45'
|
||||||
# configuration
|
# configuration
|
||||||
BACKUP_MODE=FULL
|
BACKUP_MODE=FULL
|
||||||
WITH_SERVERLOG=false
|
|
||||||
COMPRESS_DATA=false
|
COMPRESS_DATA=false
|
||||||
# result
|
# result
|
||||||
TIMELINEID=1
|
TIMELINEID=1
|
||||||
@ -209,10 +205,6 @@ absolute paths; relative paths are not allowed.
|
|||||||
The absolute path of archive WAL directory. Required on backup
|
The absolute path of archive WAL directory. Required on backup
|
||||||
and restore.
|
and restore.
|
||||||
|
|
||||||
*-S* _PATH_ / *--srvlog-path*=_PATH_::
|
|
||||||
The absolute path of server log directory. Required on backup with
|
|
||||||
server logs and restore.
|
|
||||||
|
|
||||||
*-B* _PATH_ / *--backup-path*=_PATH_::
|
*-B* _PATH_ / *--backup-path*=_PATH_::
|
||||||
The absolute path of backup catalog. This option is mandatory.
|
The absolute path of backup catalog. This option is mandatory.
|
||||||
|
|
||||||
@ -232,9 +224,6 @@ absolute paths; relative paths are not allowed.
|
|||||||
Abbreviated forms (prefix match) are also available. For example,
|
Abbreviated forms (prefix match) are also available. For example,
|
||||||
-b f means "full" backup.
|
-b f means "full" backup.
|
||||||
|
|
||||||
*-s* / *--with-serverlog*::
|
|
||||||
Backup server log files if specified.
|
|
||||||
|
|
||||||
*-Z* / *--compress-data*::
|
*-Z* / *--compress-data*::
|
||||||
Compress backup files with zlib if specified.
|
Compress backup files with zlib if specified.
|
||||||
|
|
||||||
@ -259,15 +248,6 @@ absolute paths; relative paths are not allowed.
|
|||||||
--keep-arclog-days means days to be kept. When backup is run, only
|
--keep-arclog-days means days to be kept. When backup is run, only
|
||||||
files exceeded one of those settings are deleted from archive storage.
|
files exceeded one of those settings are deleted from archive storage.
|
||||||
|
|
||||||
*--keep-srvlog-files*=_NUMBER_ / *--keep-srvlog-days*=_DAYS_::
|
|
||||||
Specify how long backuped serverlog files will be kept.
|
|
||||||
--keep-srvlog-files means number of backup files.
|
|
||||||
--keep-srvlog-days means days to be kept.
|
|
||||||
When backup is run, only files exceeded one of those settings are
|
|
||||||
deleted from server log directory (log_directory). This option works
|
|
||||||
when you specify --with-serverlog and --srvlog-path options in backup
|
|
||||||
command.
|
|
||||||
|
|
||||||
=== RESTORE OPTIONS ===
|
=== RESTORE OPTIONS ===
|
||||||
|
|
||||||
The parameters whose name start are started with --recovery refer to
|
The parameters whose name start are started with --recovery refer to
|
||||||
@ -358,16 +338,12 @@ variables or in configuration file as follows:
|
|||||||
-D --pgdata PGDATA Yes
|
-D --pgdata PGDATA Yes
|
||||||
-B --backup-path BACKUP_PATH Yes
|
-B --backup-path BACKUP_PATH Yes
|
||||||
-A --arclog-path ARCLOG_PATH Yes
|
-A --arclog-path ARCLOG_PATH Yes
|
||||||
-S --srvlog-path SRVLOG_PATH Yes
|
|
||||||
-b --backup-mode BACKUP_MODE Yes
|
-b --backup-mode BACKUP_MODE Yes
|
||||||
-s --with-serverlog WITH_SERVERLOG Yes
|
|
||||||
-Z --compress-data COMPRESS_DATA Yes
|
-Z --compress-data COMPRESS_DATA Yes
|
||||||
-C --smooth-checkpoint SMOOTH_CHECKPOINT Yes
|
-C --smooth-checkpoint SMOOTH_CHECKPOINT Yes
|
||||||
--validate VALIDATE Yes
|
--validate VALIDATE Yes
|
||||||
--keep-data-generations KEEP_DATA_GENERATIONS Yes
|
--keep-data-generations KEEP_DATA_GENERATIONS Yes
|
||||||
--keep-data-days KEEP_DATA_DAYS Yes
|
--keep-data-days KEEP_DATA_DAYS Yes
|
||||||
--keep-srvlog-files KEEP_SRVLOG_FILES Yes
|
|
||||||
--keep-srvlog-days KEEP_SRVLOG_DAYS Yes
|
|
||||||
--keep-arclog-files KEEP_ARCLOG_FILES Yes
|
--keep-arclog-files KEEP_ARCLOG_FILES Yes
|
||||||
--keep-arclog-days KEEP_ARCLOG_DAYS Yes
|
--keep-arclog-days KEEP_ARCLOG_DAYS Yes
|
||||||
--recovery-target-timeline RECOVERY_TARGET_TIMELINE Yes
|
--recovery-target-timeline RECOVERY_TARGET_TIMELINE Yes
|
||||||
|
@ -8,20 +8,14 @@ CHECKPOINT
|
|||||||
incremental database backup
|
incremental database backup
|
||||||
CHECKPOINT
|
CHECKPOINT
|
||||||
CHECKPOINT
|
CHECKPOINT
|
||||||
archived WAL and serverlog backup
|
archived WAL backup
|
||||||
stop DB during running pgbench
|
stop DB during running pgbench
|
||||||
diff files in BACKUP_PATH/backup/pg_xlog
|
diff files in BACKUP_PATH/backup/pg_xlog
|
||||||
# of files in BACKUP_PATH/backup/srvlog
|
|
||||||
1
|
|
||||||
diff files in BACKUP_PATH/backup/pg_xlog
|
diff files in BACKUP_PATH/backup/pg_xlog
|
||||||
# of files in BACKUP_PATH/backup/srvlog
|
|
||||||
2
|
|
||||||
full database backup after recovery
|
full database backup after recovery
|
||||||
CHECKPOINT
|
CHECKPOINT
|
||||||
# of files in BACKUP_PATH/backup/pg_xlog
|
# of files in BACKUP_PATH/backup/pg_xlog
|
||||||
0
|
0
|
||||||
# of files in BACKUP_PATH/backup/srvlog
|
|
||||||
2
|
|
||||||
# of symbolic links in ARCLOG_PATH
|
# of symbolic links in ARCLOG_PATH
|
||||||
0
|
0
|
||||||
# of files in BACKUP_PATH/timeline_history
|
# of files in BACKUP_PATH/timeline_history
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
results/init_test/
|
results/init_test/
|
||||||
results/init_test/backup/
|
results/init_test/backup/
|
||||||
results/init_test/backup/pg_xlog/
|
results/init_test/backup/pg_xlog/
|
||||||
results/init_test/backup/srvlog/
|
|
||||||
results/init_test/pg_rman.ini
|
results/init_test/pg_rman.ini
|
||||||
results/init_test/timeline_history/
|
results/init_test/timeline_history/
|
||||||
\! pg_rman init -B ${PWD}/results/init_test --quiet;echo $?
|
\! pg_rman init -B ${PWD}/results/init_test --quiet;echo $?
|
||||||
|
@ -12,14 +12,12 @@ Usage:
|
|||||||
Common Options:
|
Common Options:
|
||||||
-D, --pgdata=PATH location of the database storage area
|
-D, --pgdata=PATH location of the database storage area
|
||||||
-A, --arclog-path=PATH location of archive WAL storage area
|
-A, --arclog-path=PATH location of archive WAL storage area
|
||||||
-S, --srvlog-path=PATH location of server log storage area
|
|
||||||
-B, --backup-path=PATH location of the backup storage area
|
-B, --backup-path=PATH location of the backup storage area
|
||||||
-c, --check show what would have been done
|
-c, --check show what would have been done
|
||||||
-v, --verbose output process information
|
-v, --verbose output process information
|
||||||
|
|
||||||
Backup options:
|
Backup options:
|
||||||
-b, --backup-mode=MODE full, incremental, or archive
|
-b, --backup-mode=MODE full, incremental, or archive
|
||||||
-s, --with-serverlog also backup server log files
|
|
||||||
-Z, --compress-data compress data backup with zlib
|
-Z, --compress-data compress data backup with zlib
|
||||||
-C, --smooth-checkpoint do smooth checkpoint before backup
|
-C, --smooth-checkpoint do smooth checkpoint before backup
|
||||||
--validate validate backup after taking it
|
--validate validate backup after taking it
|
||||||
@ -27,8 +25,6 @@ Backup options:
|
|||||||
--keep-data-days=DAY keep enough data backup to recover to DAY days age
|
--keep-data-days=DAY keep enough data backup to recover to DAY days age
|
||||||
--keep-arclog-files=NUM keep NUM of archived WAL
|
--keep-arclog-files=NUM keep NUM of archived WAL
|
||||||
--keep-arclog-days=DAY keep archived WAL modified in DAY days
|
--keep-arclog-days=DAY keep archived WAL modified in DAY days
|
||||||
--keep-srvlog-files=NUM keep NUM of serverlogs
|
|
||||||
--keep-srvlog-days=DAY keep serverlog modified in DAY days
|
|
||||||
|
|
||||||
Restore options:
|
Restore options:
|
||||||
--recovery-target-time time stamp up to which recovery will proceed
|
--recovery-target-time time stamp up to which recovery will proceed
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
\! rm -rf ${PWD}/results/sample_backup
|
\! rm -rf ${PWD}/results/sample_backup
|
||||||
\! cp -rp data/sample_backup ${PWD}/results/sample_backup
|
\! cp -rp data/sample_backup ${PWD}/results/sample_backup
|
||||||
\! pg_rman show -B ${PWD}/results/sample_backup
|
\! pg_rman show -B ${PWD}/results/sample_backup
|
||||||
==================================================================================================
|
===========================================================================================
|
||||||
Start Mode Current TLI Parent TLI Time Data WAL Log Backup Status
|
Start Mode Current TLI Parent TLI Time Data WAL Backup Status
|
||||||
==================================================================================================
|
===========================================================================================
|
||||||
2009-06-03 17:05:53 FULL 1 0 0m ---- ---- ---- ---- RUNNING
|
2009-06-03 17:05:53 FULL 1 0 0m ---- ---- ---- RUNNING
|
||||||
2009-06-01 17:05:53 INCR 1 0 3m 9223PB 16MB ---- 162MB DONE
|
2009-06-01 17:05:53 INCR 1 0 3m 9223PB 16MB 162MB DONE
|
||||||
2009-05-31 17:05:53 FULL 1 0 3m 1242MB 9223PB ---- 242MB DONE
|
2009-05-31 17:05:53 FULL 1 0 3m 1242MB 9223PB 242MB DONE
|
||||||
\! pg_rman validate -B ${PWD}/results/sample_backup 2009-05-31 17:05:53 --debug
|
\! pg_rman validate -B ${PWD}/results/sample_backup 2009-05-31 17:05:53 --debug
|
||||||
INFO: validate: 2009-05-31 17:05:53 backup and archive log files by CRC
|
INFO: validate: 2009-05-31 17:05:53 backup and archive log files by CRC
|
||||||
LOG: database files...
|
LOG: database files...
|
||||||
@ -22,17 +22,16 @@ WARNING: CRC of backup file "PG_VERSION" must be 0 but FEF71BC1
|
|||||||
LOG: archive WAL files...
|
LOG: archive WAL files...
|
||||||
WARNING: backup 2009-06-01 17:05:53 is corrupted
|
WARNING: backup 2009-06-01 17:05:53 is corrupted
|
||||||
\! pg_rman show -a -B ${PWD}/results/sample_backup
|
\! pg_rman show -a -B ${PWD}/results/sample_backup
|
||||||
==================================================================================================
|
===========================================================================================
|
||||||
Start Mode Current TLI Parent TLI Time Data WAL Log Backup Status
|
Start Mode Current TLI Parent TLI Time Data WAL Backup Status
|
||||||
==================================================================================================
|
===========================================================================================
|
||||||
2009-06-03 17:05:53 FULL 1 0 0m ---- ---- ---- ---- RUNNING
|
2009-06-03 17:05:53 FULL 1 0 0m ---- ---- ---- RUNNING
|
||||||
2009-06-02 17:05:03 ARCH 1 0 0m ---- ---- 4335kB 162MB DELETED
|
2009-06-02 17:05:03 ARCH 1 0 0m ---- ---- 162MB DELETED
|
||||||
2009-06-01 17:05:53 INCR 1 0 3m 9223PB 16MB ---- 162MB CORRUPT
|
2009-06-01 17:05:53 INCR 1 0 3m 9223PB 16MB 162MB CORRUPT
|
||||||
2009-05-31 17:05:53 FULL 1 0 3m 1242MB 9223PB ---- 242MB OK
|
2009-05-31 17:05:53 FULL 1 0 3m 1242MB 9223PB 242MB OK
|
||||||
\! pg_rman show 2009-06-01 17:05:53 -B ${PWD}/results/sample_backup
|
\! pg_rman show 2009-06-01 17:05:53 -B ${PWD}/results/sample_backup
|
||||||
# configuration
|
# configuration
|
||||||
BACKUP_MODE=INCREMENTAL
|
BACKUP_MODE=INCREMENTAL
|
||||||
WITH_SERVERLOG=false
|
|
||||||
COMPRESS_DATA=false
|
COMPRESS_DATA=false
|
||||||
# result
|
# result
|
||||||
TIMELINEID=1
|
TIMELINEID=1
|
||||||
|
29
init.c
29
init.c
@ -52,9 +52,6 @@ do_init(void)
|
|||||||
snprintf(path, lengthof(path), "%s/%s/%s", backup_path, RESTORE_WORK_DIR,
|
snprintf(path, lengthof(path), "%s/%s/%s", backup_path, RESTORE_WORK_DIR,
|
||||||
PG_XLOG_DIR);
|
PG_XLOG_DIR);
|
||||||
dir_create_dir(path, DIR_PERMISSION);
|
dir_create_dir(path, DIR_PERMISSION);
|
||||||
snprintf(path, lengthof(path), "%s/%s/%s", backup_path, RESTORE_WORK_DIR,
|
|
||||||
SRVLOG_DIR);
|
|
||||||
dir_create_dir(path, DIR_PERMISSION);
|
|
||||||
|
|
||||||
/* create directory for timeline history files */
|
/* create directory for timeline history files */
|
||||||
join_path_components(path, backup_path, TIMELINE_HISTORY_DIR);
|
join_path_components(path, backup_path, TIMELINE_HISTORY_DIR);
|
||||||
@ -119,32 +116,6 @@ do_init(void)
|
|||||||
elog(WARNING, "ARCLOG_PATH is not set because archive_command is empty."
|
elog(WARNING, "ARCLOG_PATH is not set because archive_command is empty."
|
||||||
"Please set ARCLOG_PATH in pg_rman.ini or environmental variable");
|
"Please set ARCLOG_PATH in pg_rman.ini or environmental variable");
|
||||||
|
|
||||||
/* set SRVLOG_PATH refered with log_directory */
|
|
||||||
if (srvlog_path == NULL)
|
|
||||||
{
|
|
||||||
if (log_directory)
|
|
||||||
{
|
|
||||||
if (is_absolute_path(log_directory))
|
|
||||||
srvlog_path = pgut_strdup(log_directory);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
srvlog_path = pgut_malloc(MAXPGPATH);
|
|
||||||
join_path_components(srvlog_path, pgdata, log_directory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (pgdata)
|
|
||||||
{
|
|
||||||
/* default: log_directory = 'pg_log' */
|
|
||||||
srvlog_path = pgut_malloc(MAXPGPATH);
|
|
||||||
join_path_components(srvlog_path, pgdata, "pg_log");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (srvlog_path)
|
|
||||||
{
|
|
||||||
fprintf(fp, "SRVLOG_PATH='%s'\n", srvlog_path);
|
|
||||||
elog(INFO, "SRVLOG_PATH is set to '%s'", srvlog_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
|
17
pg_rman.c
17
pg_rman.c
@ -22,7 +22,6 @@ const char *PROGRAM_EMAIL = "https://github.com/michaelpq/pg_rman/issues";
|
|||||||
char *backup_path;
|
char *backup_path;
|
||||||
char *pgdata;
|
char *pgdata;
|
||||||
char *arclog_path;
|
char *arclog_path;
|
||||||
char *srvlog_path;
|
|
||||||
|
|
||||||
/* common configuration */
|
/* common configuration */
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
@ -35,8 +34,6 @@ pgBackup current;
|
|||||||
static bool smooth_checkpoint;
|
static bool smooth_checkpoint;
|
||||||
static int keep_arclog_files = KEEP_INFINITE;
|
static int keep_arclog_files = KEEP_INFINITE;
|
||||||
static int keep_arclog_days = KEEP_INFINITE;
|
static int keep_arclog_days = KEEP_INFINITE;
|
||||||
static int keep_srvlog_files = KEEP_INFINITE;
|
|
||||||
static int keep_srvlog_days = KEEP_INFINITE;
|
|
||||||
static int keep_data_generations = KEEP_INFINITE;
|
static int keep_data_generations = KEEP_INFINITE;
|
||||||
static int keep_data_days = KEEP_INFINITE;
|
static int keep_data_days = KEEP_INFINITE;
|
||||||
static bool backup_validate = false;
|
static bool backup_validate = false;
|
||||||
@ -60,13 +57,11 @@ static pgut_option options[] =
|
|||||||
{ 's', 'D', "pgdata", &pgdata, SOURCE_ENV },
|
{ 's', 'D', "pgdata", &pgdata, SOURCE_ENV },
|
||||||
{ 's', 'A', "arclog-path", &arclog_path, SOURCE_ENV },
|
{ 's', 'A', "arclog-path", &arclog_path, SOURCE_ENV },
|
||||||
{ 's', 'B', "backup-path", &backup_path, SOURCE_ENV },
|
{ 's', 'B', "backup-path", &backup_path, SOURCE_ENV },
|
||||||
{ 's', 'S', "srvlog-path", &srvlog_path, SOURCE_ENV },
|
|
||||||
/* common options */
|
/* common options */
|
||||||
{ 'b', 'v', "verbose", &verbose },
|
{ 'b', 'v', "verbose", &verbose },
|
||||||
{ 'b', 'c', "check", &check },
|
{ 'b', 'c', "check", &check },
|
||||||
/* backup options */
|
/* backup options */
|
||||||
{ 'f', 'b', "backup-mode", opt_backup_mode, SOURCE_ENV },
|
{ 'f', 'b', "backup-mode", opt_backup_mode, SOURCE_ENV },
|
||||||
{ 'b', 's', "with-serverlog", ¤t.with_serverlog, SOURCE_ENV },
|
|
||||||
{ 'b', 'Z', "compress-data", ¤t.compress_data, SOURCE_ENV },
|
{ 'b', 'Z', "compress-data", ¤t.compress_data, SOURCE_ENV },
|
||||||
{ 'b', 'C', "smooth-checkpoint", &smooth_checkpoint, SOURCE_ENV },
|
{ 'b', 'C', "smooth-checkpoint", &smooth_checkpoint, SOURCE_ENV },
|
||||||
/* options with only long name (keep-xxx) */
|
/* options with only long name (keep-xxx) */
|
||||||
@ -74,8 +69,6 @@ static pgut_option options[] =
|
|||||||
{ 'i', 2, "keep-data-days", &keep_data_days, SOURCE_ENV },
|
{ 'i', 2, "keep-data-days", &keep_data_days, SOURCE_ENV },
|
||||||
{ 'i', 3, "keep-arclog-files", &keep_arclog_files, SOURCE_ENV },
|
{ 'i', 3, "keep-arclog-files", &keep_arclog_files, SOURCE_ENV },
|
||||||
{ 'i', 4, "keep-arclog-days", &keep_arclog_days, SOURCE_ENV },
|
{ 'i', 4, "keep-arclog-days", &keep_arclog_days, SOURCE_ENV },
|
||||||
{ 'i', 5, "keep-srvlog-files", &keep_srvlog_files, SOURCE_ENV },
|
|
||||||
{ 'i', 6, "keep-srvlog-days", &keep_srvlog_days, SOURCE_ENV },
|
|
||||||
/* restore options */
|
/* restore options */
|
||||||
{ 's', 7, "recovery-target-time", &target_time, SOURCE_ENV },
|
{ 's', 7, "recovery-target-time", &target_time, SOURCE_ENV },
|
||||||
{ 's', 8, "recovery-target-xid", &target_xid, SOURCE_ENV },
|
{ 's', 8, "recovery-target-xid", &target_xid, SOURCE_ENV },
|
||||||
@ -163,16 +156,12 @@ main(int argc, char *argv[])
|
|||||||
elog(ERROR_ARGS, "-D, --pgdata must be an absolute path");
|
elog(ERROR_ARGS, "-D, --pgdata must be an absolute path");
|
||||||
if (arclog_path != NULL && !is_absolute_path(arclog_path))
|
if (arclog_path != NULL && !is_absolute_path(arclog_path))
|
||||||
elog(ERROR_ARGS, "-A, --arclog-path must be an absolute path");
|
elog(ERROR_ARGS, "-A, --arclog-path must be an absolute path");
|
||||||
if (srvlog_path != NULL && !is_absolute_path(srvlog_path))
|
|
||||||
elog(ERROR_ARGS, "-S, --srvlog-path must be an absolute path");
|
|
||||||
|
|
||||||
/* setup exclusion list for file search */
|
/* setup exclusion list for file search */
|
||||||
for (i = 0; pgdata_exclude[i]; i++) /* find first empty slot */
|
for (i = 0; pgdata_exclude[i]; i++) /* find first empty slot */
|
||||||
;
|
;
|
||||||
if (arclog_path)
|
if (arclog_path)
|
||||||
pgdata_exclude[i++] = arclog_path;
|
pgdata_exclude[i++] = arclog_path;
|
||||||
if (srvlog_path)
|
|
||||||
pgdata_exclude[i++] = srvlog_path;
|
|
||||||
|
|
||||||
/* do actual operation */
|
/* do actual operation */
|
||||||
if (pg_strcasecmp(cmd, "init") == 0)
|
if (pg_strcasecmp(cmd, "init") == 0)
|
||||||
@ -184,8 +173,6 @@ main(int argc, char *argv[])
|
|||||||
bkupopt.smooth_checkpoint = smooth_checkpoint;
|
bkupopt.smooth_checkpoint = smooth_checkpoint;
|
||||||
bkupopt.keep_arclog_files = keep_arclog_files;
|
bkupopt.keep_arclog_files = keep_arclog_files;
|
||||||
bkupopt.keep_arclog_days = keep_arclog_days;
|
bkupopt.keep_arclog_days = keep_arclog_days;
|
||||||
bkupopt.keep_srvlog_files = keep_srvlog_files;
|
|
||||||
bkupopt.keep_srvlog_days = keep_srvlog_days;
|
|
||||||
bkupopt.keep_data_generations = keep_data_generations;
|
bkupopt.keep_data_generations = keep_data_generations;
|
||||||
bkupopt.keep_data_days = keep_data_days;
|
bkupopt.keep_data_days = keep_data_days;
|
||||||
|
|
||||||
@ -234,13 +221,11 @@ pgut_help(bool details)
|
|||||||
printf(_("\nCommon Options:\n"));
|
printf(_("\nCommon Options:\n"));
|
||||||
printf(_(" -D, --pgdata=PATH location of the database storage area\n"));
|
printf(_(" -D, --pgdata=PATH location of the database storage area\n"));
|
||||||
printf(_(" -A, --arclog-path=PATH location of archive WAL storage area\n"));
|
printf(_(" -A, --arclog-path=PATH location of archive WAL storage area\n"));
|
||||||
printf(_(" -S, --srvlog-path=PATH location of server log storage area\n"));
|
|
||||||
printf(_(" -B, --backup-path=PATH location of the backup storage area\n"));
|
printf(_(" -B, --backup-path=PATH location of the backup storage area\n"));
|
||||||
printf(_(" -c, --check show what would have been done\n"));
|
printf(_(" -c, --check show what would have been done\n"));
|
||||||
printf(_(" -v, --verbose output process information\n"));
|
printf(_(" -v, --verbose output process information\n"));
|
||||||
printf(_("\nBackup options:\n"));
|
printf(_("\nBackup options:\n"));
|
||||||
printf(_(" -b, --backup-mode=MODE full, incremental, or archive\n"));
|
printf(_(" -b, --backup-mode=MODE full, incremental, or archive\n"));
|
||||||
printf(_(" -s, --with-serverlog also backup server log files\n"));
|
|
||||||
printf(_(" -Z, --compress-data compress data backup with zlib\n"));
|
printf(_(" -Z, --compress-data compress data backup with zlib\n"));
|
||||||
printf(_(" -C, --smooth-checkpoint do smooth checkpoint before backup\n"));
|
printf(_(" -C, --smooth-checkpoint do smooth checkpoint before backup\n"));
|
||||||
printf(_(" --validate validate backup after taking it\n"));
|
printf(_(" --validate validate backup after taking it\n"));
|
||||||
@ -248,8 +233,6 @@ pgut_help(bool details)
|
|||||||
printf(_(" --keep-data-days=DAY keep enough data backup to recover to DAY days age\n"));
|
printf(_(" --keep-data-days=DAY keep enough data backup to recover to DAY days age\n"));
|
||||||
printf(_(" --keep-arclog-files=NUM keep NUM of archived WAL\n"));
|
printf(_(" --keep-arclog-files=NUM keep NUM of archived WAL\n"));
|
||||||
printf(_(" --keep-arclog-days=DAY keep archived WAL modified in DAY days\n"));
|
printf(_(" --keep-arclog-days=DAY keep archived WAL modified in DAY days\n"));
|
||||||
printf(_(" --keep-srvlog-files=NUM keep NUM of serverlogs\n"));
|
|
||||||
printf(_(" --keep-srvlog-days=DAY keep serverlog modified in DAY days\n"));
|
|
||||||
printf(_("\nRestore options:\n"));
|
printf(_("\nRestore options:\n"));
|
||||||
printf(_(" --recovery-target-time time stamp up to which recovery will proceed\n"));
|
printf(_(" --recovery-target-time time stamp up to which recovery will proceed\n"));
|
||||||
printf(_(" --recovery-target-xid transaction ID up to which recovery will proceed\n"));
|
printf(_(" --recovery-target-xid transaction ID up to which recovery will proceed\n"));
|
||||||
|
10
pg_rman.h
10
pg_rman.h
@ -26,7 +26,6 @@
|
|||||||
/* Directory/File names */
|
/* Directory/File names */
|
||||||
#define DATABASE_DIR "database"
|
#define DATABASE_DIR "database"
|
||||||
#define ARCLOG_DIR "arclog"
|
#define ARCLOG_DIR "arclog"
|
||||||
#define SRVLOG_DIR "srvlog"
|
|
||||||
#define RESTORE_WORK_DIR "backup"
|
#define RESTORE_WORK_DIR "backup"
|
||||||
#define PG_XLOG_DIR "pg_xlog"
|
#define PG_XLOG_DIR "pg_xlog"
|
||||||
#define PG_TBLSPC_DIR "pg_tblspc"
|
#define PG_TBLSPC_DIR "pg_tblspc"
|
||||||
@ -36,7 +35,6 @@
|
|||||||
#define MKDIRS_SH_FILE "mkdirs.sh"
|
#define MKDIRS_SH_FILE "mkdirs.sh"
|
||||||
#define DATABASE_FILE_LIST "file_database.txt"
|
#define DATABASE_FILE_LIST "file_database.txt"
|
||||||
#define ARCLOG_FILE_LIST "file_arclog.txt"
|
#define ARCLOG_FILE_LIST "file_arclog.txt"
|
||||||
#define SRVLOG_FILE_LIST "file_srvlog.txt"
|
|
||||||
#define SNAPSHOT_SCRIPT_FILE "snapshot_script"
|
#define SNAPSHOT_SCRIPT_FILE "snapshot_script"
|
||||||
#define PG_BACKUP_LABEL_FILE "backup_label"
|
#define PG_BACKUP_LABEL_FILE "backup_label"
|
||||||
#define PG_BLACK_LIST "black_list"
|
#define PG_BLACK_LIST "black_list"
|
||||||
@ -129,7 +127,6 @@ typedef struct pgBackup
|
|||||||
{
|
{
|
||||||
/* Backup Level */
|
/* Backup Level */
|
||||||
BackupMode backup_mode;
|
BackupMode backup_mode;
|
||||||
bool with_serverlog;
|
|
||||||
bool compress_data;
|
bool compress_data;
|
||||||
|
|
||||||
/* Status - one of BACKUP_STATUS_xxx */
|
/* Status - one of BACKUP_STATUS_xxx */
|
||||||
@ -153,8 +150,6 @@ typedef struct pgBackup
|
|||||||
int64 data_bytes;
|
int64 data_bytes;
|
||||||
/* Amount of data for WAL archives */
|
/* Amount of data for WAL archives */
|
||||||
int64 arclog_bytes;
|
int64 arclog_bytes;
|
||||||
/* Amount of data for server logs */
|
|
||||||
int64 srvlog_bytes;
|
|
||||||
/* Total size of backup */
|
/* Total size of backup */
|
||||||
int64 backup_bytes;
|
int64 backup_bytes;
|
||||||
|
|
||||||
@ -168,8 +163,6 @@ typedef struct pgBackupOption
|
|||||||
bool smooth_checkpoint;
|
bool smooth_checkpoint;
|
||||||
int keep_arclog_files;
|
int keep_arclog_files;
|
||||||
int keep_arclog_days;
|
int keep_arclog_days;
|
||||||
int keep_srvlog_files;
|
|
||||||
int keep_srvlog_days;
|
|
||||||
int keep_data_generations;
|
int keep_data_generations;
|
||||||
int keep_data_days;
|
int keep_data_days;
|
||||||
} pgBackupOption;
|
} pgBackupOption;
|
||||||
@ -219,7 +212,6 @@ typedef enum CompressionMode
|
|||||||
extern char *backup_path;
|
extern char *backup_path;
|
||||||
extern char *pgdata;
|
extern char *pgdata;
|
||||||
extern char *arclog_path;
|
extern char *arclog_path;
|
||||||
extern char *srvlog_path;
|
|
||||||
|
|
||||||
/* common configuration */
|
/* common configuration */
|
||||||
extern bool verbose;
|
extern bool verbose;
|
||||||
@ -272,8 +264,6 @@ extern pgBackup *catalog_get_last_data_backup(parray *backup_list,
|
|||||||
TimeLineID tli);
|
TimeLineID tli);
|
||||||
extern pgBackup *catalog_get_last_arclog_backup(parray *backup_list,
|
extern pgBackup *catalog_get_last_arclog_backup(parray *backup_list,
|
||||||
TimeLineID tli);
|
TimeLineID tli);
|
||||||
extern pgBackup *catalog_get_last_srvlog_backup(parray *backup_list,
|
|
||||||
TimeLineID tli);
|
|
||||||
|
|
||||||
extern int catalog_lock(void);
|
extern int catalog_lock(void);
|
||||||
extern void catalog_unlock(void);
|
extern void catalog_unlock(void);
|
||||||
|
13
restore.c
13
restore.c
@ -67,9 +67,6 @@ do_restore(const char *target_time,
|
|||||||
if (arclog_path == NULL)
|
if (arclog_path == NULL)
|
||||||
elog(ERROR_ARGS,
|
elog(ERROR_ARGS,
|
||||||
_("required parameter not specified: ARCLOG_PATH (-A, --arclog-path)"));
|
_("required parameter not specified: ARCLOG_PATH (-A, --arclog-path)"));
|
||||||
if (srvlog_path == NULL)
|
|
||||||
elog(ERROR_ARGS,
|
|
||||||
_("required parameter not specified: SRVLOG_PATH (-S, --srvlog-path)"));
|
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
@ -114,7 +111,7 @@ do_restore(const char *target_time,
|
|||||||
printf(_("target timeline ID = %u\n"), target_tli);
|
printf(_("target timeline ID = %u\n"), target_tli);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* backup online WAL and serverlog */
|
/* backup online WAL */
|
||||||
backup_online_files(cur_tli != 0 && cur_tli != backup_tli);
|
backup_online_files(cur_tli != 0 && cur_tli != backup_tli);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -626,7 +623,7 @@ backup_online_files(bool re_recovery)
|
|||||||
if (verbose && !check)
|
if (verbose && !check)
|
||||||
{
|
{
|
||||||
printf(_("----------------------------------------\n"));
|
printf(_("----------------------------------------\n"));
|
||||||
printf(_("backup online WAL and serverlog start\n"));
|
printf(_("backup online WAL start\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get list of files in $BACKUP_PATH/backup/pg_xlog */
|
/* get list of files in $BACKUP_PATH/backup/pg_xlog */
|
||||||
@ -655,12 +652,6 @@ backup_online_files(bool re_recovery)
|
|||||||
RESTORE_WORK_DIR, PG_XLOG_DIR);
|
RESTORE_WORK_DIR, PG_XLOG_DIR);
|
||||||
dir_create_dir(work_path, DIR_PERMISSION);
|
dir_create_dir(work_path, DIR_PERMISSION);
|
||||||
dir_copy_files(pg_xlog_path, work_path);
|
dir_copy_files(pg_xlog_path, work_path);
|
||||||
|
|
||||||
/* backup serverlog */
|
|
||||||
snprintf(work_path, lengthof(work_path), "%s/%s/%s", backup_path,
|
|
||||||
RESTORE_WORK_DIR, SRVLOG_DIR);
|
|
||||||
dir_create_dir(work_path, DIR_PERMISSION);
|
|
||||||
dir_copy_files(srvlog_path, work_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
15
show.c
15
show.c
@ -161,9 +161,9 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* show header */
|
/* show header */
|
||||||
fputs("==================================================================================================\n", out);
|
fputs("===========================================================================================\n", out);
|
||||||
fputs("Start Mode Current TLI Parent TLI Time Data WAL Log Backup Status \n", out);
|
fputs("Start Mode Current TLI Parent TLI Time Data WAL Backup Status \n", out);
|
||||||
fputs("==================================================================================================\n", out);
|
fputs("===========================================================================================\n", out);
|
||||||
|
|
||||||
for (i = 0; i < parray_num(backup_list); i++)
|
for (i = 0; i < parray_num(backup_list); i++)
|
||||||
{
|
{
|
||||||
@ -174,7 +174,6 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
|
|||||||
char duration[20] = "----";
|
char duration[20] = "----";
|
||||||
char data_bytes_str[10] = "----";
|
char data_bytes_str[10] = "----";
|
||||||
char arclog_bytes_str[10] = "----";
|
char arclog_bytes_str[10] = "----";
|
||||||
char srvlog_bytes_str[10] = "----";
|
|
||||||
char backup_bytes_str[10];
|
char backup_bytes_str[10];
|
||||||
|
|
||||||
backup = parray_get(backup_list, i);
|
backup = parray_get(backup_list, i);
|
||||||
@ -200,11 +199,6 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
|
|||||||
pretty_size(backup->arclog_bytes, arclog_bytes_str,
|
pretty_size(backup->arclog_bytes, arclog_bytes_str,
|
||||||
lengthof(arclog_bytes_str));
|
lengthof(arclog_bytes_str));
|
||||||
|
|
||||||
/* Calculate amount of data for server logs */
|
|
||||||
if (backup->with_serverlog)
|
|
||||||
pretty_size(backup->srvlog_bytes, srvlog_bytes_str,
|
|
||||||
lengthof(srvlog_bytes_str));
|
|
||||||
|
|
||||||
/* Calculate amount of data for total backup */
|
/* Calculate amount of data for total backup */
|
||||||
pretty_size(backup->backup_bytes, backup_bytes_str,
|
pretty_size(backup->backup_bytes, backup_bytes_str,
|
||||||
lengthof(backup_bytes_str));
|
lengthof(backup_bytes_str));
|
||||||
@ -212,7 +206,7 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
|
|||||||
/* Get parent timeline before printing */
|
/* Get parent timeline before printing */
|
||||||
parent_tli = get_parent_tli(backup->tli);
|
parent_tli = get_parent_tli(backup->tli);
|
||||||
|
|
||||||
fprintf(out, "%-19s %-4s %10d %10d %5s %6s %6s %6s %6s %s\n",
|
fprintf(out, "%-19s %-4s %10d %10d %5s %6s %6s %6s %s\n",
|
||||||
timestamp,
|
timestamp,
|
||||||
modes[backup->backup_mode],
|
modes[backup->backup_mode],
|
||||||
backup->tli,
|
backup->tli,
|
||||||
@ -220,7 +214,6 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
|
|||||||
duration,
|
duration,
|
||||||
data_bytes_str,
|
data_bytes_str,
|
||||||
arclog_bytes_str,
|
arclog_bytes_str,
|
||||||
srvlog_bytes_str,
|
|
||||||
backup_bytes_str,
|
backup_bytes_str,
|
||||||
status2str(backup->status));
|
status2str(backup->status));
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ export PGDATA=$BASE_PATH/results/sample_database
|
|||||||
|
|
||||||
export BACKUP_PATH=$BASE_PATH/results/sample_backup2
|
export BACKUP_PATH=$BASE_PATH/results/sample_backup2
|
||||||
export ARCLOG_PATH=$BASE_PATH/results/arclog
|
export ARCLOG_PATH=$BASE_PATH/results/arclog
|
||||||
export SRVLOG_PATH=$PGDATA/pg_log
|
|
||||||
export COMPRESS_DATA=YES
|
export COMPRESS_DATA=YES
|
||||||
XLOG_PATH=$PGDATA/pg_xlog
|
XLOG_PATH=$PGDATA/pg_xlog
|
||||||
TBLSPC_PATH=$BASE_PATH/results/tblspc
|
TBLSPC_PATH=$BASE_PATH/results/tblspc
|
||||||
@ -16,15 +15,10 @@ TEST_PGPORT=54321
|
|||||||
# configuration
|
# configuration
|
||||||
SCALE=1
|
SCALE=1
|
||||||
DURATION=10
|
DURATION=10
|
||||||
ISOLATE_SRVLOG=0
|
|
||||||
ISOLATE_WAL=0
|
ISOLATE_WAL=0
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
"-s")
|
|
||||||
ISOLATE_SRVLOG=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
"-w")
|
"-w")
|
||||||
ISOLATE_WAL=1
|
ISOLATE_WAL=1
|
||||||
shift
|
shift
|
||||||
@ -55,9 +49,7 @@ done
|
|||||||
pg_ctl stop -m immediate > /dev/null 2>&1
|
pg_ctl stop -m immediate > /dev/null 2>&1
|
||||||
rm -rf $PGDATA
|
rm -rf $PGDATA
|
||||||
rm -rf $BASE_PATH/results/pg_xlog
|
rm -rf $BASE_PATH/results/pg_xlog
|
||||||
rm -rf $BASE_PATH/results/srvlog
|
|
||||||
rm -rf $ARCLOG_PATH
|
rm -rf $ARCLOG_PATH
|
||||||
rm -rf $SRVLOG_PATH
|
|
||||||
rm -rf $TBLSPC_PATH
|
rm -rf $TBLSPC_PATH
|
||||||
|
|
||||||
# create new backup catalog
|
# create new backup catalog
|
||||||
@ -84,16 +76,6 @@ EOF
|
|||||||
mkdir -p $ARCLOG_PATH
|
mkdir -p $ARCLOG_PATH
|
||||||
mkdir -p $TBLSPC_PATH
|
mkdir -p $TBLSPC_PATH
|
||||||
|
|
||||||
# determine serverlog directory
|
|
||||||
if [ "$ISOLATE_SRVLOG" -ne 0 ]; then
|
|
||||||
export SRVLOG_PATH=$BASE_PATH/results/srvlog
|
|
||||||
echo "log_directory = '$SRVLOG_PATH'" >> $PGDATA/postgresql.conf
|
|
||||||
mkdir -p $SRVLOG_PATH
|
|
||||||
else
|
|
||||||
export SRVLOG_PATH=$PGDATA/pg_log
|
|
||||||
echo "log_directory = 'pg_log'" >> $PGDATA/postgresql.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# isolate online WAL
|
# isolate online WAL
|
||||||
if [ "$ISOLATE_WAL" -ne 0 ]; then
|
if [ "$ISOLATE_WAL" -ne 0 ]; then
|
||||||
XLOG_PATH=$BASE_PATH/results/pg_xlog
|
XLOG_PATH=$BASE_PATH/results/pg_xlog
|
||||||
@ -145,7 +127,7 @@ psql --no-psqlrc -p $TEST_PGPORT postgres -c "checkpoint"
|
|||||||
pg_rman -w -p $TEST_PGPORT backup -b i --verbose -d postgres > $BASE_PATH/results/log_incr2 2>&1
|
pg_rman -w -p $TEST_PGPORT backup -b i --verbose -d postgres > $BASE_PATH/results/log_incr2 2>&1
|
||||||
|
|
||||||
pgbench -p $TEST_PGPORT -T $DURATION -c 10 pgbench >> $BASE_PATH/results/pgbench.log 2>&1
|
pgbench -p $TEST_PGPORT -T $DURATION -c 10 pgbench >> $BASE_PATH/results/pgbench.log 2>&1
|
||||||
echo "archived WAL and serverlog backup"
|
echo "archived WAL backup"
|
||||||
#pg_rman -p $TEST_PGPORT backup -b a --verbose -d postgres > $BASE_PATH/results/log_arclog 2>&1
|
#pg_rman -p $TEST_PGPORT backup -b a --verbose -d postgres > $BASE_PATH/results/log_arclog 2>&1
|
||||||
pg_rman -w -p $TEST_PGPORT backup -b a --verbose -d postgres > $BASE_PATH/results/log_arclog 2>&1
|
pg_rman -w -p $TEST_PGPORT backup -b a --verbose -d postgres > $BASE_PATH/results/log_arclog 2>&1
|
||||||
|
|
||||||
@ -178,11 +160,9 @@ if [ "$CUR_TLI" != "$CUR_TLI_R" ]; then
|
|||||||
echo "failed: bad timeline ID" CUR_TLI=$CUR_TLI CUR_TLI_R=$CUR_TLI_R
|
echo "failed: bad timeline ID" CUR_TLI=$CUR_TLI CUR_TLI_R=$CUR_TLI_R
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Backup of online-WAL and serverlog.
|
# Backup of online-WAL
|
||||||
echo "diff files in BACKUP_PATH/backup/pg_xlog"
|
echo "diff files in BACKUP_PATH/backup/pg_xlog"
|
||||||
diff -r $PGDATA/pg_xlog $BACKUP_PATH/backup/pg_xlog
|
diff -r $PGDATA/pg_xlog $BACKUP_PATH/backup/pg_xlog
|
||||||
echo "# of files in BACKUP_PATH/backup/srvlog"
|
|
||||||
find $BACKUP_PATH/backup/srvlog -type f | wc -l | tr -d ' '
|
|
||||||
|
|
||||||
# recovery database
|
# recovery database
|
||||||
pg_ctl start -w -t 3600 > /dev/null 2>&1
|
pg_ctl start -w -t 3600 > /dev/null 2>&1
|
||||||
@ -201,11 +181,9 @@ if [ "$CUR_TLI" != "$CUR_TLI_R" ]; then
|
|||||||
echo "failed: bad timeline ID" CUR_TLI=$CUR_TLI CUR_TLI_R=$CUR_TLI_R
|
echo "failed: bad timeline ID" CUR_TLI=$CUR_TLI CUR_TLI_R=$CUR_TLI_R
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Backup of online-WAL and serverlog.
|
# Backup of online-WAL
|
||||||
echo "diff files in BACKUP_PATH/backup/pg_xlog"
|
echo "diff files in BACKUP_PATH/backup/pg_xlog"
|
||||||
diff -r $PGDATA/pg_xlog $BACKUP_PATH/backup/pg_xlog
|
diff -r $PGDATA/pg_xlog $BACKUP_PATH/backup/pg_xlog
|
||||||
echo "# of files in BACKUP_PATH/backup/srvlog"
|
|
||||||
find $BACKUP_PATH/backup/srvlog -type f | wc -l | tr -d ' '
|
|
||||||
|
|
||||||
# re-recovery database
|
# re-recovery database
|
||||||
pg_ctl start -w -t 3600 > /dev/null 2>&1
|
pg_ctl start -w -t 3600 > /dev/null 2>&1
|
||||||
@ -221,11 +199,9 @@ psql --no-psqlrc -p $TEST_PGPORT postgres -c "checkpoint"
|
|||||||
#pg_rman -p $TEST_PGPORT backup -b f --verbose -d postgres > $BASE_PATH/results/log_full2 2>&1
|
#pg_rman -p $TEST_PGPORT backup -b f --verbose -d postgres > $BASE_PATH/results/log_full2 2>&1
|
||||||
pg_rman -w -p $TEST_PGPORT backup -b f --verbose -d postgres > $BASE_PATH/results/log_full2 2>&1
|
pg_rman -w -p $TEST_PGPORT backup -b f --verbose -d postgres > $BASE_PATH/results/log_full2 2>&1
|
||||||
|
|
||||||
# Backup of online-WAL should been deleted, but serverlog remain.
|
# Backup of online-WAL should been deleted
|
||||||
echo "# of files in BACKUP_PATH/backup/pg_xlog"
|
echo "# of files in BACKUP_PATH/backup/pg_xlog"
|
||||||
find $BACKUP_PATH/backup/pg_xlog -type f | wc -l | tr -d ' '
|
find $BACKUP_PATH/backup/pg_xlog -type f | wc -l | tr -d ' '
|
||||||
echo "# of files in BACKUP_PATH/backup/srvlog"
|
|
||||||
find $BACKUP_PATH/backup/srvlog -type f | wc -l | tr -d ' '
|
|
||||||
|
|
||||||
# Symbolic links in $ARCLOG_PATH should be deleted.
|
# Symbolic links in $ARCLOG_PATH should be deleted.
|
||||||
echo "# of symbolic links in ARCLOG_PATH"
|
echo "# of symbolic links in ARCLOG_PATH"
|
||||||
|
@ -10,14 +10,11 @@ BASE_PATH=`pwd`
|
|||||||
# List of environment variables is defined in catalog.c.
|
# List of environment variables is defined in catalog.c.
|
||||||
unset BACKUP_PATH
|
unset BACKUP_PATH
|
||||||
unset ARCLOG_PATH
|
unset ARCLOG_PATH
|
||||||
unset SRVLOG_PATH
|
|
||||||
unset BACKUP_MODE
|
unset BACKUP_MODE
|
||||||
unset COMPRESS_DATA
|
unset COMPRESS_DATA
|
||||||
unset KEEP_ARCLOG_DAYS
|
unset KEEP_ARCLOG_DAYS
|
||||||
unset KEEP_DATA_GENERATIONS
|
unset KEEP_DATA_GENERATIONS
|
||||||
unset KEEP_DATA_DAYS
|
unset KEEP_DATA_DAYS
|
||||||
unset KEEP_SRVLOG_FILES
|
|
||||||
unset KEEP_SRVLOG_DAYS
|
|
||||||
|
|
||||||
export PGDATA=$BASE_PATH/results/sample_database
|
export PGDATA=$BASE_PATH/results/sample_database
|
||||||
|
|
||||||
|
15
validate.c
15
validate.c
@ -89,9 +89,6 @@ pgBackupValidate(pgBackup *backup,
|
|||||||
if (backup->backup_mode == BACKUP_MODE_ARCHIVE)
|
if (backup->backup_mode == BACKUP_MODE_ARCHIVE)
|
||||||
elog(INFO, "validate: %s archive log files by %s",
|
elog(INFO, "validate: %s archive log files by %s",
|
||||||
timestamp, (size_only ? "SIZE" : "CRC"));
|
timestamp, (size_only ? "SIZE" : "CRC"));
|
||||||
else if (backup->with_serverlog)
|
|
||||||
elog(INFO, "validate: %s server log files by %s",
|
|
||||||
timestamp, (size_only ? "SIZE" : "CRC"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,18 +118,6 @@ pgBackupValidate(pgBackup *backup,
|
|||||||
parray_walk(files, pgFileFree);
|
parray_walk(files, pgFileFree);
|
||||||
parray_free(files);
|
parray_free(files);
|
||||||
|
|
||||||
if (backup->with_serverlog)
|
|
||||||
{
|
|
||||||
elog(LOG, "server log files...");
|
|
||||||
pgBackupGetPath(backup, base_path, lengthof(base_path), SRVLOG_DIR);
|
|
||||||
pgBackupGetPath(backup, path, lengthof(path), SRVLOG_FILE_LIST);
|
|
||||||
files = dir_read_file_list(base_path, path);
|
|
||||||
if (!pgBackupValidateFiles(files, base_path, size_only))
|
|
||||||
corrupted = true;
|
|
||||||
parray_walk(files, pgFileFree);
|
|
||||||
parray_free(files);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* update status to OK */
|
/* update status to OK */
|
||||||
if (corrupted)
|
if (corrupted)
|
||||||
backup->status = BACKUP_STATUS_CORRUPT;
|
backup->status = BACKUP_STATUS_CORRUPT;
|
||||||
|
Reference in New Issue
Block a user