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

Commitf77d141

Browse files
author
Michael Paquier
committed
Simplify beginning of database backup
It was unclear what was being errored out at the beginning of theprocess. But it happens that it is just necessary to check if thebackup running is only an archive or not, then return a NULL filelist before continuing process. This should be part of some safetychecks though.
1 parent4b0f88e commitf77d141

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

‎backup.c

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void create_file_list(parray *files, const char *root, const char *prefix
6363
staticTimeLineIDget_current_timeline(void);
6464

6565
/*
66-
* Take a backup of database.
66+
* Take a backup of database and return the list of files backed up.
6767
*/
6868
staticparray*
6969
do_backup_database(parray*backup_list,pgBackupOptionbkupopt)
@@ -75,36 +75,34 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
7575
charpath[MAXPGPATH];
7676
charlabel[1024];
7777
XLogRecPtr*lsn=NULL;
78-
charprev_file_txt[MAXPGPATH];/* path of the previous backup list file */
79-
boolhas_backup_label= true;/* flag if backup_label is there */
78+
charprev_file_txt[MAXPGPATH];/* path of the previous backup
79+
* list file */
80+
boolhas_backup_label= true;/* flag if backup_label is there */
8081

8182
/* repack the options */
8283
boolsmooth_checkpoint=bkupopt.smooth_checkpoint;
8384

84-
if (!HAVE_DATABASE(&current)) {
85-
/* check if arclog backup. if arclog backup and no suitable full backup, */
86-
/* take full backup instead. */
87-
if (HAVE_ARCLOG(&current)) {
88-
pgBackup*prev_backup;
85+
/*
86+
* In archive backup mode, check if there is an already validated
87+
* full backup on current timeline.
88+
*/
89+
if (current.backup_mode==BACKUP_MODE_ARCHIVE)
90+
{
91+
pgBackup*prev_backup;
8992

90-
/* find last completed database backup */
91-
prev_backup=catalog_get_last_data_backup(backup_list);
92-
if (prev_backup==NULL)
93-
{
94-
elog(ERROR_SYSTEM,_("There is indeed a full backup but it is not validated."
95-
"So I can't take any arclog backup."
96-
"Please validate it and retry."));
97-
///elog(INFO, _("no previous full backup, performing a full backup instead"));
98-
///current.backup_mode = BACKUP_MODE_FULL;
99-
}
93+
prev_backup=catalog_get_last_data_backup(backup_list);
94+
if (prev_backup==NULL)
95+
{
96+
elog(ERROR_SYSTEM,_("Full backup detected but it is not "
97+
"validated so archive backup cannot be taken. "
98+
"backup. Validate it and retry."));
10099
}
101-
else
102-
returnNULL;
100+
returnNULL;
103101
}
104102

105103
elog(INFO,_("database backup start"));
106104

107-
/*initialize size summary */
105+
/*Initialize size summary */
108106
current.total_data_bytes=0;
109107
current.read_data_bytes=0;
110108

@@ -123,14 +121,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
123121
/* If backup_label does not exist in $PGDATA, stop taking backup */
124122
snprintf(path,lengthof(path),"%s/backup_label",pgdata);
125123
make_native_path(path);
126-
if (!fileExists(path)) {
124+
if (!fileExists(path))
127125
has_backup_label= false;
128-
}
126+
129127
snprintf(path,lengthof(path),"%s/recovery.conf",pgdata);
130128
make_native_path(path);
131-
if (fileExists(path)) {
129+
if (fileExists(path))
132130
current.is_from_standby= true;
133-
}
131+
134132
if (!has_backup_label&& !current.is_from_standby)
135133
{
136134
if (verbose)
@@ -140,10 +138,8 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
140138
}
141139

142140
/*
143-
* list directories and symbolic links with the physical path to make
144-
* mkdirs.sh
145-
* Sort in order of path.
146-
* omit $PGDATA.
141+
* List directories and symbolic links with the physical path to make
142+
* mkdirs.sh, then sort them in order of path. Omit $PGDATA.
147143
*/
148144
files=parray_new();
149145
dir_list_file(files,pgdata,NULL, false, false);
@@ -433,7 +429,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
433429

434430

435431
/*
436-
*backup archived WAL incrementally.
432+
*Backup archived WAL incrementally.
437433
*/
438434
staticparray*
439435
do_backup_arclog(parray*backup_list)
@@ -449,8 +445,9 @@ do_backup_arclog(parray *backup_list)
449445
int64arclog_write_bytes=0;
450446
charlast_wal[MAXPGPATH];
451447

452-
if (!HAVE_ARCLOG(&current))
453-
returnNULL;
448+
Assert(current.backup_mode==BACKUP_MODE_ARCHIVE||
449+
current.backup_mode==BACKUP_MODE_INCREMENTAL||
450+
current.backup_mode==BACKUP_MODE_FULL);
454451

455452
if (verbose)
456453
{

‎pg_rman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ typedef struct pgBackup
144144
time_trecovery_time;
145145
uint32recovery_xid;
146146

147-
/* Size (-1 meansnot-backup'ed) */
147+
/* Size (-1 meansnothing was backed up) */
148148
int64total_data_bytes;
149149
int64read_data_bytes;
150150
int64read_arclog_bytes;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp