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

Commit96a5f13

Browse files
committed
Save and compare system-identifier.
1 parent90897a5 commit96a5f13

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

‎init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ do_init(void)
3434
char*log_directory=NULL;
3535
char*archive_command=NULL;
3636
FILE*fp;
37+
uint64_system_identifier;
3738

3839
structdirent**dp;
3940
intresults;
@@ -58,6 +59,7 @@ do_init(void)
5859
parse_postgresql_conf(path,&log_directory,&archive_command);
5960
}
6061

62+
_system_identifier=get_system_identifier(false);
6163
/* create pg_probackup.conf */
6264
join_path_components(path,backup_path,PG_RMAN_INI_FILE);
6365
fp=fopen(path,"wt");
@@ -67,6 +69,7 @@ do_init(void)
6769
join_path_components(arclog_path_dir,backup_path,"wal");
6870
dir_create_dir(arclog_path_dir,DIR_PERMISSION);
6971

72+
fprintf(fp,"system-identifier = %li\n",_system_identifier);
7073
fprintf(fp,"\n");
7174
fclose(fp);
7275

‎pg_probackup.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ boolfrom_replica = false;
4040
staticboolbackup_logs= false;
4141
boolprogress= false;
4242
booldelete_wal= false;
43+
uint64system_identifier=0;
4344

4445
/* restore configuration */
4546
staticchar*target_time;
@@ -74,6 +75,8 @@ static pgut_option options[] =
7475
{'u',6,"timeline",&target_tli,SOURCE_CMDLINE },
7576
/* delete options */
7677
{'b',12,"wal",&delete_wal },
78+
/* other */
79+
{'U',13,"system-identifier",&system_identifier,SOURCE_FILE },
7780
{0 }
7881
};
7982

@@ -188,10 +191,16 @@ main(int argc, char *argv[])
188191
{
189192
pgBackupOptionbkupopt;
190193
intres;
194+
uint64_system_identifier;
191195
bkupopt.smooth_checkpoint=smooth_checkpoint;
192196
bkupopt.keep_data_generations=keep_data_generations;
193197
bkupopt.keep_data_days=keep_data_days;
194198

199+
_system_identifier=get_system_identifier(true);
200+
if (_system_identifier!=system_identifier)
201+
elog(ERROR,"Backup directory was initialized for system id = %ld, but target system id = %ld",
202+
system_identifier,_system_identifier);
203+
195204
/* Do the backup */
196205
res=do_backup(bkupopt);
197206
if (res!=0)

‎pg_probackup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ extern bool stream_wal;
205205
externboolfrom_replica;
206206
externboolprogress;
207207
externbooldelete_wal;
208+
externuint64system_identifier;
208209

209210
/* in backup.c */
210211
externintdo_backup(pgBackupOptionbkupopt);
@@ -310,6 +311,7 @@ extern XLogRecPtr get_last_ptrack_lsn(void);
310311
externuint32get_data_checksum_version(boolsafe);
311312
externchar*base36enc(long unsignedintvalue);
312313
externlong unsignedintbase36dec(constchar*text);
314+
externuint64get_system_identifier(boolsafe);
313315

314316
/* in status.c */
315317
externboolis_pg_running(void);

‎util.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,23 @@ get_current_timeline(bool safe)
122122
returnControlFile.checkPointCopy.ThisTimeLineID;
123123
}
124124

125+
uint64
126+
get_system_identifier(boolsafe)
127+
{
128+
ControlFileDataControlFile;
129+
char*buffer;
130+
size_tsize;
131+
132+
/* First fetch file... */
133+
buffer=slurpFile(pgdata,"global/pg_control",&size,safe);
134+
if (buffer==NULL)
135+
return0;
136+
digestControlFile(&ControlFile,buffer,size);
137+
pg_free(buffer);
138+
139+
returnControlFile.system_identifier;
140+
}
141+
125142
uint32
126143
get_data_checksum_version(boolsafe)
127144
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp