mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-11-24 08:52:38 +02:00
Use --stream option only for backup. Add STREAM to show command.
This commit is contained in:
parent
6130be7b26
commit
24c840392f
1
backup.c
1
backup.c
@ -486,6 +486,7 @@ do_backup(pgBackupOption bkupopt)
|
||||
current.recovery_xid = 0;
|
||||
current.recovery_time = (time_t) 0;
|
||||
current.checksum_version = get_data_checksum_version(true);
|
||||
current.stream = stream_wal;
|
||||
|
||||
/* create backup directory and backup.ini */
|
||||
if (!check)
|
||||
|
@ -289,6 +289,7 @@ pgBackupWriteResultSection(FILE *out, pgBackup *backup)
|
||||
fprintf(out, "BLOCK_SIZE=%u\n", backup->block_size);
|
||||
fprintf(out, "XLOG_BLOCK_SIZE=%u\n", backup->wal_block_size);
|
||||
fprintf(out, "CHECKSUM_VERSION=%u\n", backup->checksum_version);
|
||||
fprintf(out, "STREAM=%u\n", backup->stream);
|
||||
|
||||
fprintf(out, "STATUS=%s\n", status2str(backup->status));
|
||||
}
|
||||
@ -344,6 +345,7 @@ catalog_read_ini(const char *path)
|
||||
{ 'u', 0, "block-size" , NULL, SOURCE_ENV },
|
||||
{ 'u', 0, "xlog-block-size" , NULL, SOURCE_ENV },
|
||||
{ 'u', 0, "checksum_version" , NULL, SOURCE_ENV },
|
||||
{ 'u', 0, "stream" , NULL, SOURCE_ENV },
|
||||
{ 's', 0, "status" , NULL, SOURCE_ENV },
|
||||
{ 0 }
|
||||
};
|
||||
@ -367,6 +369,7 @@ catalog_read_ini(const char *path)
|
||||
options[i++].var = &backup->block_size;
|
||||
options[i++].var = &backup->wal_block_size;
|
||||
options[i++].var = &backup->checksum_version;
|
||||
options[i++].var = &backup->stream;
|
||||
options[i++].var = &status;
|
||||
Assert(i == lengthof(options) - 1);
|
||||
|
||||
@ -508,4 +511,5 @@ catalog_init_config(pgBackup *backup)
|
||||
backup->recovery_xid = 0;
|
||||
backup->recovery_time = (time_t) 0;
|
||||
backup->data_bytes = BYTES_INVALID;
|
||||
backup->stream = false;
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ Common Options:
|
||||
-B, --backup-path=PATH location of the backup storage area
|
||||
-c, --check show what would have been done
|
||||
-j, --threads=NUM num threads for backup and restore
|
||||
--stream use stream for save/restore WAL during backup
|
||||
--progress show progress copy files
|
||||
|
||||
Backup options:
|
||||
-b, --backup-mode=MODE full,page,ptrack
|
||||
-C, --smooth-checkpoint do smooth checkpoint before backup
|
||||
--stream use stream for save/restore WAL during backup
|
||||
--keep-data-generations=N keep GENERATION of full data backup
|
||||
--keep-data-days=DAY keep enough data backup to recover to DAY days age
|
||||
--backup-pg-log start backup pg_log directory
|
||||
|
@ -223,11 +223,11 @@ pgut_help(bool details)
|
||||
printf(_(" -B, --backup-path=PATH location of the backup storage area\n"));
|
||||
printf(_(" -c, --check show what would have been done\n"));
|
||||
printf(_(" -j, --threads=NUM num threads for backup and restore\n"));
|
||||
printf(_(" --stream use stream for save/restore WAL during backup\n"));
|
||||
printf(_(" --progress show progress copy files\n"));
|
||||
printf(_("\nBackup options:\n"));
|
||||
printf(_(" -b, --backup-mode=MODE full,page,ptrack\n"));
|
||||
printf(_(" -C, --smooth-checkpoint do smooth checkpoint before backup\n"));
|
||||
printf(_(" --stream use stream for save/restore WAL during backup\n"));
|
||||
printf(_(" --keep-data-generations=N keep GENERATION of full data backup\n"));
|
||||
printf(_(" --keep-data-days=DAY keep enough data backup to recover to DAY days age\n"));
|
||||
printf(_(" --backup-pg-log start backup pg_log directory\n"));
|
||||
|
@ -133,6 +133,7 @@ typedef struct pgBackup
|
||||
uint32 block_size;
|
||||
uint32 wal_block_size;
|
||||
uint32 checksum_version;
|
||||
bool stream;
|
||||
} pgBackup;
|
||||
|
||||
typedef struct pgBackupOption
|
||||
|
67
restore.c
67
restore.c
@ -23,7 +23,6 @@ typedef struct
|
||||
pgBackup *backup;
|
||||
} restore_files_args;
|
||||
|
||||
static void backup_online_files(bool re_recovery);
|
||||
static void restore_database(pgBackup *backup);
|
||||
static void create_recovery_conf(const char *target_time,
|
||||
const char *target_xid,
|
||||
@ -104,9 +103,6 @@ do_restore(const char *target_time,
|
||||
elog(LOG, "latest full backup timeline ID = %u", backup_tli);
|
||||
elog(LOG, "target timeline ID = %u", target_tli);
|
||||
|
||||
/* backup online WAL */
|
||||
backup_online_files(cur_tli != 0 && cur_tli != backup_tli);
|
||||
|
||||
/*
|
||||
* Clear restore destination, but don't remove $PGDATA.
|
||||
* To remove symbolic link, get file list with "omit_symlink = false".
|
||||
@ -181,26 +177,22 @@ base_backup_found:
|
||||
!satisfy_recovery_target(backup, rt))
|
||||
continue;
|
||||
|
||||
print_backup_lsn(backup);
|
||||
stream_wal = backup->stream;
|
||||
|
||||
print_backup_lsn(backup);
|
||||
restore_database(backup);
|
||||
last_restored_index = i;
|
||||
}
|
||||
|
||||
for (i = last_restored_index; i >= 0; i--)
|
||||
{
|
||||
char xlogpath[MAXPGPATH];
|
||||
elog(LOG, "searching archived WAL...");
|
||||
if (!stream_wal)
|
||||
for (i = last_restored_index; i >= 0; i--)
|
||||
{
|
||||
elog(LOG, "searching archived WAL...");
|
||||
|
||||
search_next_wal(arclog_path, &need_lsn, timelines);
|
||||
search_next_wal(arclog_path, &need_lsn, timelines);
|
||||
|
||||
elog(LOG, "searching online WAL...");
|
||||
|
||||
join_path_components(xlogpath, pgdata, PG_XLOG_DIR);
|
||||
search_next_wal(xlogpath, &need_lsn, timelines);
|
||||
|
||||
elog(LOG, "all necessary files are found");
|
||||
}
|
||||
elog(LOG, "all necessary files are found");
|
||||
}
|
||||
|
||||
/* create recovery.conf */
|
||||
if (!stream_wal)
|
||||
@ -481,47 +473,6 @@ create_recovery_conf(const char *target_time,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
backup_online_files(bool re_recovery)
|
||||
{
|
||||
char work_path[MAXPGPATH];
|
||||
char pg_xlog_path[MAXPGPATH];
|
||||
bool files_exist;
|
||||
parray *files;
|
||||
|
||||
if (!check)
|
||||
{
|
||||
elog(LOG, "----------------------------------------");
|
||||
elog(LOG, "backup online WAL start");
|
||||
}
|
||||
|
||||
/* get list of files in $BACKUP_PATH/backup/pg_xlog */
|
||||
files = parray_new();
|
||||
snprintf(work_path, lengthof(work_path), "%s/%s/%s", backup_path,
|
||||
RESTORE_WORK_DIR, PG_XLOG_DIR);
|
||||
dir_list_file(files, work_path, NULL, true, false);
|
||||
|
||||
files_exist = parray_num(files) > 0;
|
||||
|
||||
parray_walk(files, pgFileFree);
|
||||
parray_free(files);
|
||||
|
||||
/* If files exist in RESTORE_WORK_DIR and not re-recovery, use them. */
|
||||
if (files_exist && !re_recovery)
|
||||
{
|
||||
elog(LOG, "online WALs have been already backed up, use them");
|
||||
return;
|
||||
}
|
||||
|
||||
/* backup online WAL */
|
||||
snprintf(pg_xlog_path, lengthof(pg_xlog_path), "%s/pg_xlog", pgdata);
|
||||
snprintf(work_path, lengthof(work_path), "%s/%s/%s", backup_path,
|
||||
RESTORE_WORK_DIR, PG_XLOG_DIR);
|
||||
dir_create_dir(work_path, DIR_PERMISSION);
|
||||
dir_copy_files(pg_xlog_path, work_path);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Try to read a timeline's history file.
|
||||
*
|
||||
|
12
show.c
12
show.c
@ -165,14 +165,14 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
|
||||
int i;
|
||||
|
||||
/* show header */
|
||||
fputs("===================================================================================\n", out);
|
||||
fputs("ID Recovery time Mode Current TLI Parent TLI Time Data Status \n", out);
|
||||
fputs("===================================================================================\n", out);
|
||||
fputs("=========================================================================================\n", out);
|
||||
fputs("ID Recovery time Mode Current TLI Parent TLI Time Data Status \n", out);
|
||||
fputs("=========================================================================================\n", out);
|
||||
|
||||
for (i = 0; i < parray_num(backup_list); i++)
|
||||
{
|
||||
pgBackup *backup;
|
||||
const char *modes[] = { "", "PAGE", "PTRACK", "FULL"};
|
||||
const char *modes[] = { "", "PAGE", "PTRACK", "FULL", "PAGE+STREAM", "PTRACK+STERAM", "FULL+STREAM"};
|
||||
TimeLineID parent_tli;
|
||||
char timestamp[20];
|
||||
char duration[20] = "----";
|
||||
@ -200,10 +200,10 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
|
||||
/* Get parent timeline before printing */
|
||||
parent_tli = get_parent_tli(backup->tli);
|
||||
|
||||
fprintf(out, "%-8s %-19s %-6s %10d %10d %5s %6s %s \n",
|
||||
fprintf(out, "%-8s %-19s %-12s %10d %10d %5s %6s %s \n",
|
||||
base36enc(backup->start_time),
|
||||
timestamp,
|
||||
modes[backup->backup_mode],
|
||||
modes[backup->backup_mode*(backup->stream+1)],
|
||||
backup->tli,
|
||||
parent_tli,
|
||||
duration,
|
||||
|
Loading…
Reference in New Issue
Block a user