Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit24c8403

Browse files
committed
Use --stream option only for backup. Add STREAM to show command.
1 parent6130be7 commit24c8403

File tree

7 files changed

+23
-66
lines changed

7 files changed

+23
-66
lines changed

‎backup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ do_backup(pgBackupOption bkupopt)
486486
current.recovery_xid=0;
487487
current.recovery_time= (time_t)0;
488488
current.checksum_version=get_data_checksum_version(true);
489+
current.stream=stream_wal;
489490

490491
/* create backup directory and backup.ini */
491492
if (!check)

‎catalog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ pgBackupWriteResultSection(FILE *out, pgBackup *backup)
289289
fprintf(out,"BLOCK_SIZE=%u\n",backup->block_size);
290290
fprintf(out,"XLOG_BLOCK_SIZE=%u\n",backup->wal_block_size);
291291
fprintf(out,"CHECKSUM_VERSION=%u\n",backup->checksum_version);
292+
fprintf(out,"STREAM=%u\n",backup->stream);
292293

293294
fprintf(out,"STATUS=%s\n",status2str(backup->status));
294295
}
@@ -344,6 +345,7 @@ catalog_read_ini(const char *path)
344345
{'u',0,"block-size",NULL,SOURCE_ENV },
345346
{'u',0,"xlog-block-size",NULL,SOURCE_ENV },
346347
{'u',0,"checksum_version",NULL,SOURCE_ENV },
348+
{'u',0,"stream",NULL,SOURCE_ENV },
347349
{'s',0,"status",NULL,SOURCE_ENV },
348350
{0 }
349351
};
@@ -367,6 +369,7 @@ catalog_read_ini(const char *path)
367369
options[i++].var=&backup->block_size;
368370
options[i++].var=&backup->wal_block_size;
369371
options[i++].var=&backup->checksum_version;
372+
options[i++].var=&backup->stream;
370373
options[i++].var=&status;
371374
Assert(i==lengthof(options)-1);
372375

@@ -508,4 +511,5 @@ catalog_init_config(pgBackup *backup)
508511
backup->recovery_xid=0;
509512
backup->recovery_time= (time_t)0;
510513
backup->data_bytes=BYTES_INVALID;
514+
backup->stream= false;
511515
}

‎expected/option.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Common Options:
1616
-B, --backup-path=PATH location of the backup storage area
1717
-c, --check show what would have been done
1818
-j, --threads=NUM num threads for backup and restore
19-
--stream use stream for save/restore WAL during backup
2019
--progress show progress copy files
2120

2221
Backup options:
2322
-b, --backup-mode=MODE full,page,ptrack
2423
-C, --smooth-checkpoint do smooth checkpoint before backup
24+
--stream use stream for save/restore WAL during backup
2525
--keep-data-generations=N keep GENERATION of full data backup
2626
--keep-data-days=DAY keep enough data backup to recover to DAY days age
2727
--backup-pg-log start backup pg_log directory

‎pg_arman.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ pgut_help(bool details)
223223
printf(_(" -B, --backup-path=PATH location of the backup storage area\n"));
224224
printf(_(" -c, --check show what would have been done\n"));
225225
printf(_(" -j, --threads=NUM num threads for backup and restore\n"));
226-
printf(_(" --stream use stream for save/restore WAL during backup\n"));
227226
printf(_(" --progress show progress copy files\n"));
228227
printf(_("\nBackup options:\n"));
229228
printf(_(" -b, --backup-mode=MODE full,page,ptrack\n"));
230229
printf(_(" -C, --smooth-checkpoint do smooth checkpoint before backup\n"));
230+
printf(_(" --stream use stream for save/restore WAL during backup\n"));
231231
printf(_(" --keep-data-generations=N keep GENERATION of full data backup\n"));
232232
printf(_(" --keep-data-days=DAY keep enough data backup to recover to DAY days age\n"));
233233
printf(_(" --backup-pg-log start backup pg_log directory\n"));

‎pg_arman.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ typedef struct pgBackup
133133
uint32block_size;
134134
uint32wal_block_size;
135135
uint32checksum_version;
136+
boolstream;
136137
}pgBackup;
137138

138139
typedefstructpgBackupOption

‎restore.c

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ typedef struct
2323
pgBackup*backup;
2424
}restore_files_args;
2525

26-
staticvoidbackup_online_files(boolre_recovery);
2726
staticvoidrestore_database(pgBackup*backup);
2827
staticvoidcreate_recovery_conf(constchar*target_time,
2928
constchar*target_xid,
@@ -104,9 +103,6 @@ do_restore(const char *target_time,
104103
elog(LOG,"latest full backup timeline ID = %u",backup_tli);
105104
elog(LOG,"target timeline ID = %u",target_tli);
106105

107-
/* backup online WAL */
108-
backup_online_files(cur_tli!=0&&cur_tli!=backup_tli);
109-
110106
/*
111107
* Clear restore destination, but don't remove $PGDATA.
112108
* To remove symbolic link, get file list with "omit_symlink = false".
@@ -181,26 +177,22 @@ do_restore(const char *target_time,
181177
!satisfy_recovery_target(backup,rt))
182178
continue;
183179

184-
print_backup_lsn(backup);
180+
stream_wal=backup->stream;
185181

182+
print_backup_lsn(backup);
186183
restore_database(backup);
187184
last_restored_index=i;
188185
}
189186

190-
for (i=last_restored_index;i >=0;i--)
191-
{
192-
charxlogpath[MAXPGPATH];
193-
elog(LOG,"searching archived WAL...");
194-
195-
search_next_wal(arclog_path,&need_lsn,timelines);
196-
197-
elog(LOG,"searching online WAL...");
187+
if (!stream_wal)
188+
for (i=last_restored_index;i >=0;i--)
189+
{
190+
elog(LOG,"searching archived WAL...");
198191

199-
join_path_components(xlogpath,pgdata,PG_XLOG_DIR);
200-
search_next_wal(xlogpath,&need_lsn,timelines);
192+
search_next_wal(arclog_path,&need_lsn,timelines);
201193

202-
elog(LOG,"all necessary files are found");
203-
}
194+
elog(LOG,"all necessary files are found");
195+
}
204196

205197
/* create recovery.conf */
206198
if (!stream_wal)
@@ -481,47 +473,6 @@ create_recovery_conf(const char *target_time,
481473
}
482474
}
483475

484-
staticvoid
485-
backup_online_files(boolre_recovery)
486-
{
487-
charwork_path[MAXPGPATH];
488-
charpg_xlog_path[MAXPGPATH];
489-
boolfiles_exist;
490-
parray*files;
491-
492-
if (!check)
493-
{
494-
elog(LOG,"----------------------------------------");
495-
elog(LOG,"backup online WAL start");
496-
}
497-
498-
/* get list of files in $BACKUP_PATH/backup/pg_xlog */
499-
files=parray_new();
500-
snprintf(work_path,lengthof(work_path),"%s/%s/%s",backup_path,
501-
RESTORE_WORK_DIR,PG_XLOG_DIR);
502-
dir_list_file(files,work_path,NULL, true, false);
503-
504-
files_exist=parray_num(files)>0;
505-
506-
parray_walk(files,pgFileFree);
507-
parray_free(files);
508-
509-
/* If files exist in RESTORE_WORK_DIR and not re-recovery, use them. */
510-
if (files_exist&& !re_recovery)
511-
{
512-
elog(LOG,"online WALs have been already backed up, use them");
513-
return;
514-
}
515-
516-
/* backup online WAL */
517-
snprintf(pg_xlog_path,lengthof(pg_xlog_path),"%s/pg_xlog",pgdata);
518-
snprintf(work_path,lengthof(work_path),"%s/%s/%s",backup_path,
519-
RESTORE_WORK_DIR,PG_XLOG_DIR);
520-
dir_create_dir(work_path,DIR_PERMISSION);
521-
dir_copy_files(pg_xlog_path,work_path);
522-
}
523-
524-
525476
/*
526477
* Try to read a timeline's history file.
527478
*

‎show.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
165165
inti;
166166

167167
/* show header */
168-
fputs("===================================================================================\n",out);
169-
fputs("ID Recovery time Mode Current TLI Parent TLI Time Data Status \n",out);
170-
fputs("===================================================================================\n",out);
168+
fputs("=========================================================================================\n",out);
169+
fputs("ID Recovery time ModeCurrent TLI Parent TLI Time Data Status \n",out);
170+
fputs("=========================================================================================\n",out);
171171

172172
for (i=0;i<parray_num(backup_list);i++)
173173
{
174174
pgBackup*backup;
175-
constchar*modes[]= {"","PAGE","PTRACK","FULL"};
175+
constchar*modes[]= {"","PAGE","PTRACK","FULL","PAGE+STREAM","PTRACK+STERAM","FULL+STREAM"};
176176
TimeLineIDparent_tli;
177177
chartimestamp[20];
178178
charduration[20]="----";
@@ -200,10 +200,10 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
200200
/* Get parent timeline before printing */
201201
parent_tli=get_parent_tli(backup->tli);
202202

203-
fprintf(out,"%-8s %-19s %-6s %10d %10d %5s %6s %s \n",
203+
fprintf(out,"%-8s %-19s %-12s %10d %10d %5s %6s %s \n",
204204
base36enc(backup->start_time),
205205
timestamp,
206-
modes[backup->backup_mode],
206+
modes[backup->backup_mode*(backup->stream+1)],
207207
backup->tli,
208208
parent_tli,
209209
duration,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp