@@ -63,7 +63,7 @@ static void create_file_list(parray *files, const char *root, const char *prefix
6363static TimeLineID get_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 */
6868static parray *
6969do_backup_database (parray * backup_list ,pgBackupOption bkupopt )
@@ -75,36 +75,34 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
7575char path [MAXPGPATH ];
7676char label [1024 ];
7777XLogRecPtr * 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 */
8081
8182/* repack the options */
8283bool smooth_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- return NULL ;
100+ return NULL ;
103101}
104102
105103elog (INFO ,_ ("database backup start" ));
106104
107- /*initialize size summary */
105+ /*Initialize size summary */
108106current .total_data_bytes = 0 ;
109107current .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 */
124122snprintf (path ,lengthof (path ),"%s/backup_label" ,pgdata );
125123make_native_path (path );
126- if (!fileExists (path )) {
124+ if (!fileExists (path ))
127125has_backup_label = false;
128- }
126+
129127snprintf (path ,lengthof (path ),"%s/recovery.conf" ,pgdata );
130128make_native_path (path );
131- if (fileExists (path )) {
129+ if (fileExists (path ))
132130current .is_from_standby = true;
133- }
131+
134132if (!has_backup_label && !current .is_from_standby )
135133{
136134if (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 */
148144files = parray_new ();
149145dir_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 */
438434static parray *
439435do_backup_arclog (parray * backup_list )
@@ -449,8 +445,9 @@ do_backup_arclog(parray *backup_list)
449445int64 arclog_write_bytes = 0 ;
450446char last_wal [MAXPGPATH ];
451447
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 );
454451
455452if (verbose )
456453{