@@ -30,7 +30,7 @@ static void backup_cleanup(bool fatal, void *userdata);
3030static void delete_old_files (const char * root ,parray * files ,int keep_files ,
3131int keep_days ,int server_version ,bool is_arclog );
3232static void backup_files (const char * from_root ,const char * to_root ,
33- parray * files ,parray * prev_files ,XLogRecPtr * lsn ,bool compress_data );
33+ parray * files ,parray * prev_files ,const XLogRecPtr * lsn ,bool compress );
3434static parray * do_backup_database (parray * backup_list ,bool smooth_checkpoint );
3535static parray * do_backup_arclog (parray * backup_list );
3636static parray * do_backup_srvlog (parray * backup_list );
@@ -137,7 +137,7 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
137137files = parray_new ();
138138dir_list_file (files ,pgdata ,pgdata_exclude , true, false);
139139
140- /* mark filesas 'datafile' which are under base/global/pg_tblspc */
140+ /* mark filesthat are possible datafile as 'datafile' */
141141for (i = 0 ;i < parray_num (files );i ++ )
142142{
143143pgFile * file = (pgFile * )parray_get (files ,i );
@@ -148,7 +148,7 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
148148if (!S_ISREG (file -> mode ))
149149continue ;
150150
151- /* data files are under base/ global/ pg_tblspc */
151+ /* data files are under" base", " global", or " pg_tblspc" */
152152relative = file -> path + strlen (pgdata )+ 1 ;
153153if (!path_is_prefix_of_path ("base" ,relative )&&
154154!path_is_prefix_of_path ("global" ,relative )&&
@@ -214,16 +214,16 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
214214static parray *
215215do_backup_arclog (parray * backup_list )
216216{
217- int i ;
218- parray * files ;
219- parray * prev_files = NULL ;/* file list of previous database backup */
220- FILE * fp ;
221- char path [MAXPGPATH ];
222- char timeline_dir [MAXPGPATH ];
223- char prev_file_txt [MAXPGPATH ];
224- pgBackup * prev_backup ;
225- int64 arclog_write_bytes = 0 ;
226- char last_wal [MAXPGPATH ];
217+ int i ;
218+ parray * files ;
219+ parray * prev_files = NULL ;/* file list of previous database backup */
220+ FILE * fp ;
221+ char path [MAXPGPATH ];
222+ char timeline_dir [MAXPGPATH ];
223+ char prev_file_txt [MAXPGPATH ];
224+ pgBackup * prev_backup ;
225+ int64 arclog_write_bytes = 0 ;
226+ char last_wal [MAXPGPATH ];
227227
228228if (!HAVE_ARCLOG (& current ))
229229return NULL ;
@@ -345,14 +345,14 @@ do_backup_arclog(parray *backup_list)
345345static parray *
346346do_backup_srvlog (parray * backup_list )
347347{
348- int i ;
349- parray * files ;
350- parray * prev_files = NULL ;/* file list of previous database backup */
351- FILE * fp ;
352- char path [MAXPGPATH ];
353- char prev_file_txt [MAXPGPATH ];
354- pgBackup * prev_backup ;
355- int64 srvlog_write_bytes = 0 ;
348+ int i ;
349+ parray * files ;
350+ parray * prev_files = NULL ;/* file list of previous database backup */
351+ FILE * fp ;
352+ char path [MAXPGPATH ];
353+ char prev_file_txt [MAXPGPATH ];
354+ pgBackup * prev_backup ;
355+ int64 srvlog_write_bytes = 0 ;
356356
357357if (!current .with_serverlog )
358358return NULL ;
@@ -818,10 +818,14 @@ backup_cleanup(bool fatal, void *userdata)
818818
819819/* take incremental backup. */
820820static void
821- backup_files (const char * from_root ,const char * to_root ,parray * files ,
822- parray * prev_files ,XLogRecPtr * lsn ,bool compress_data )
821+ backup_files (const char * from_root ,
822+ const char * to_root ,
823+ parray * files ,
824+ parray * prev_files ,
825+ const XLogRecPtr * lsn ,
826+ bool compress )
823827{
824- int i ;
828+ int i ;
825829struct timeval tv ;
826830
827831/* sort pathname ascending */
@@ -832,8 +836,9 @@ backup_files(const char *from_root, const char *to_root, parray *files,
832836/* backup a file or create a directory */
833837for (i = 0 ;i < parray_num (files );i ++ )
834838{
835- int ret ;
836- struct stat buf ;
839+ int ret ;
840+ struct stat buf ;
841+
837842pgFile * file = (pgFile * )parray_get (files ,i );
838843
839844/* check for interrupt */
@@ -869,6 +874,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
869874if (S_ISDIR (buf .st_mode ))
870875{
871876char dirpath [MAXPGPATH ];
877+
872878snprintf (dirpath ,lengthof (dirpath ),"%s/%s" ,to_root ,
873879file -> path + strlen (from_root )+ 1 );
874880if (!check )
@@ -918,7 +924,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
918924/* copy the file into backup */
919925if (file -> is_datafile )
920926{
921- backup_data_file (from_root ,to_root ,file ,lsn ,compress_data );
927+ backup_data_file (from_root ,to_root ,file ,lsn ,compress );
922928if (file -> write_size == 0 && file -> read_size > 0 )
923929{
924930/* record as skipped file in file_xxx.txt */
@@ -930,7 +936,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
930936}
931937else
932938copy_file (from_root ,to_root ,file ,
933- compress_data ?COMPRESSION :NO_COMPRESSION );
939+ compress ?COMPRESSION :NO_COMPRESSION );
934940
935941if (verbose )
936942{
@@ -965,11 +971,10 @@ delete_old_files(const char *root,
965971int server_version ,
966972bool is_arclog )
967973{
968- int i ;
969- int j ;
970- int file_num = 0 ;
971- time_t days_threashold =
972- current .start_time - (keep_days * 60 * 60 * 24 );
974+ int i ;
975+ int j ;
976+ int file_num = 0 ;
977+ time_t days_threshold = current .start_time - (keep_days * 60 * 60 * 24 );
973978
974979if (verbose )
975980{
@@ -990,7 +995,7 @@ delete_old_files(const char *root,
990995root ,files_str ,days_str );
991996}
992997
993- /* delete files which satisfy bothcondition */
998+ /* delete files which satisfy bothconditions */
994999if (keep_files == KEEP_INFINITE || keep_days == KEEP_INFINITE )
9951000{
9961001elog (LOG ,"%s() infinite" ,__FUNCTION__ );
@@ -1003,7 +1008,7 @@ delete_old_files(const char *root,
10031008pgFile * file = (pgFile * )parray_get (files ,i );
10041009
10051010elog (LOG ,"%s() %s" ,__FUNCTION__ ,file -> path );
1006- /* Deletecomplete WAL only. */
1011+ /* Deletecompleted WALs only. */
10071012if (is_arclog && !xlog_is_complete_wal (file ,server_version ))
10081013{
10091014elog (LOG ,"%s() not complete WAL" ,__FUNCTION__ );
@@ -1013,17 +1018,17 @@ delete_old_files(const char *root,
10131018file_num ++ ;
10141019
10151020/*
1016- * If the mtime of the file is older than thethreashold and there are
1021+ * If the mtime of the file is older than thethreshold and there are
10171022 * enough number of files newer than the files, delete the file.
10181023 */
1019- if (file -> mtime >=days_threashold )
1024+ if (file -> mtime >=days_threshold )
10201025{
10211026elog (LOG ,"%s() %lu is not older than %lu" ,__FUNCTION__ ,
1022- file -> mtime ,days_threashold );
1027+ file -> mtime ,days_threshold );
10231028continue ;
10241029}
10251030elog (LOG ,"%s() %lu is older than %lu" ,__FUNCTION__ ,
1026- file -> mtime ,days_threashold );
1031+ file -> mtime ,days_threshold );
10271032
10281033if (file_num <=keep_files )
10291034{
@@ -1035,7 +1040,7 @@ delete_old_files(const char *root,
10351040if (verbose )
10361041printf (_ ("delete \"%s\"\n" ),file -> path + strlen (root )+ 1 );
10371042
1038- /* delete corresponding backup history file ifany */
1043+ /* delete corresponding backup history file ifexists */
10391044file = (pgFile * )parray_remove (files ,i );
10401045for (j = parray_num (files )- 1 ;j >=0 ;j -- )
10411046{