@@ -63,7 +63,7 @@ static void create_file_list(parray *files, const char *root, const char *prefix
63
63
static TimeLineID get_current_timeline (void );
64
64
65
65
/*
66
- * Take a backup of database.
66
+ * Take a backup of database and return the list of files backed up .
67
67
*/
68
68
static parray *
69
69
do_backup_database (parray * backup_list ,pgBackupOption bkupopt )
@@ -75,36 +75,34 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
75
75
char path [MAXPGPATH ];
76
76
char label [1024 ];
77
77
XLogRecPtr * lsn = NULL ;
78
- char prev_file_txt [MAXPGPATH ];/* path of the previous backup list file */
79
- bool has_backup_label = true;/* flag if backup_label is there */
78
+ char prev_file_txt [MAXPGPATH ];/* path of the previous backup
79
+ * list file */
80
+ bool has_backup_label = true;/* flag if backup_label is there */
80
81
81
82
/* repack the options */
82
83
bool smooth_checkpoint = bkupopt .smooth_checkpoint ;
83
84
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 ;
89
92
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." ));
100
99
}
101
- else
102
- return NULL ;
100
+ return NULL ;
103
101
}
104
102
105
103
elog (INFO ,_ ("database backup start" ));
106
104
107
- /*initialize size summary */
105
+ /*Initialize size summary */
108
106
current .total_data_bytes = 0 ;
109
107
current .read_data_bytes = 0 ;
110
108
@@ -123,14 +121,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
123
121
/* If backup_label does not exist in $PGDATA, stop taking backup */
124
122
snprintf (path ,lengthof (path ),"%s/backup_label" ,pgdata );
125
123
make_native_path (path );
126
- if (!fileExists (path )) {
124
+ if (!fileExists (path ))
127
125
has_backup_label = false;
128
- }
126
+
129
127
snprintf (path ,lengthof (path ),"%s/recovery.conf" ,pgdata );
130
128
make_native_path (path );
131
- if (fileExists (path )) {
129
+ if (fileExists (path ))
132
130
current .is_from_standby = true;
133
- }
131
+
134
132
if (!has_backup_label && !current .is_from_standby )
135
133
{
136
134
if (verbose )
@@ -140,10 +138,8 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
140
138
}
141
139
142
140
/*
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.
147
143
*/
148
144
files = parray_new ();
149
145
dir_list_file (files ,pgdata ,NULL , false, false);
@@ -433,7 +429,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
433
429
434
430
435
431
/*
436
- *backup archived WAL incrementally.
432
+ *Backup archived WAL incrementally.
437
433
*/
438
434
static parray *
439
435
do_backup_arclog (parray * backup_list )
@@ -449,8 +445,9 @@ do_backup_arclog(parray *backup_list)
449
445
int64 arclog_write_bytes = 0 ;
450
446
char last_wal [MAXPGPATH ];
451
447
452
- if (!HAVE_ARCLOG (& current ))
453
- return NULL ;
448
+ Assert (current .backup_mode == BACKUP_MODE_ARCHIVE ||
449
+ current .backup_mode == BACKUP_MODE_INCREMENTAL ||
450
+ current .backup_mode == BACKUP_MODE_FULL );
454
451
455
452
if (verbose )
456
453
{