@@ -30,7 +30,7 @@ static void backup_cleanup(bool fatal, void *userdata);
30
30
static void delete_old_files (const char * root ,parray * files ,int keep_files ,
31
31
int keep_days ,int server_version ,bool is_arclog );
32
32
static 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 );
34
34
static parray * do_backup_database (parray * backup_list ,bool smooth_checkpoint );
35
35
static parray * do_backup_arclog (parray * backup_list );
36
36
static parray * do_backup_srvlog (parray * backup_list );
@@ -137,7 +137,7 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
137
137
files = parray_new ();
138
138
dir_list_file (files ,pgdata ,pgdata_exclude , true, false);
139
139
140
- /* mark filesas 'datafile' which are under base/global/pg_tblspc */
140
+ /* mark filesthat are possible datafile as 'datafile' */
141
141
for (i = 0 ;i < parray_num (files );i ++ )
142
142
{
143
143
pgFile * file = (pgFile * )parray_get (files ,i );
@@ -148,7 +148,7 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
148
148
if (!S_ISREG (file -> mode ))
149
149
continue ;
150
150
151
- /* data files are under base/ global/ pg_tblspc */
151
+ /* data files are under" base", " global", or " pg_tblspc" */
152
152
relative = file -> path + strlen (pgdata )+ 1 ;
153
153
if (!path_is_prefix_of_path ("base" ,relative )&&
154
154
!path_is_prefix_of_path ("global" ,relative )&&
@@ -214,16 +214,16 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
214
214
static parray *
215
215
do_backup_arclog (parray * backup_list )
216
216
{
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 ];
227
227
228
228
if (!HAVE_ARCLOG (& current ))
229
229
return NULL ;
@@ -345,14 +345,14 @@ do_backup_arclog(parray *backup_list)
345
345
static parray *
346
346
do_backup_srvlog (parray * backup_list )
347
347
{
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 ;
356
356
357
357
if (!current .with_serverlog )
358
358
return NULL ;
@@ -818,10 +818,14 @@ backup_cleanup(bool fatal, void *userdata)
818
818
819
819
/* take incremental backup. */
820
820
static 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 )
823
827
{
824
- int i ;
828
+ int i ;
825
829
struct timeval tv ;
826
830
827
831
/* sort pathname ascending */
@@ -832,8 +836,9 @@ backup_files(const char *from_root, const char *to_root, parray *files,
832
836
/* backup a file or create a directory */
833
837
for (i = 0 ;i < parray_num (files );i ++ )
834
838
{
835
- int ret ;
836
- struct stat buf ;
839
+ int ret ;
840
+ struct stat buf ;
841
+
837
842
pgFile * file = (pgFile * )parray_get (files ,i );
838
843
839
844
/* check for interrupt */
@@ -869,6 +874,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
869
874
if (S_ISDIR (buf .st_mode ))
870
875
{
871
876
char dirpath [MAXPGPATH ];
877
+
872
878
snprintf (dirpath ,lengthof (dirpath ),"%s/%s" ,to_root ,
873
879
file -> path + strlen (from_root )+ 1 );
874
880
if (!check )
@@ -918,7 +924,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
918
924
/* copy the file into backup */
919
925
if (file -> is_datafile )
920
926
{
921
- backup_data_file (from_root ,to_root ,file ,lsn ,compress_data );
927
+ backup_data_file (from_root ,to_root ,file ,lsn ,compress );
922
928
if (file -> write_size == 0 && file -> read_size > 0 )
923
929
{
924
930
/* record as skipped file in file_xxx.txt */
@@ -930,7 +936,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
930
936
}
931
937
else
932
938
copy_file (from_root ,to_root ,file ,
933
- compress_data ?COMPRESSION :NO_COMPRESSION );
939
+ compress ?COMPRESSION :NO_COMPRESSION );
934
940
935
941
if (verbose )
936
942
{
@@ -965,11 +971,10 @@ delete_old_files(const char *root,
965
971
int server_version ,
966
972
bool is_arclog )
967
973
{
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 );
973
978
974
979
if (verbose )
975
980
{
@@ -990,7 +995,7 @@ delete_old_files(const char *root,
990
995
root ,files_str ,days_str );
991
996
}
992
997
993
- /* delete files which satisfy bothcondition */
998
+ /* delete files which satisfy bothconditions */
994
999
if (keep_files == KEEP_INFINITE || keep_days == KEEP_INFINITE )
995
1000
{
996
1001
elog (LOG ,"%s() infinite" ,__FUNCTION__ );
@@ -1003,7 +1008,7 @@ delete_old_files(const char *root,
1003
1008
pgFile * file = (pgFile * )parray_get (files ,i );
1004
1009
1005
1010
elog (LOG ,"%s() %s" ,__FUNCTION__ ,file -> path );
1006
- /* Deletecomplete WAL only. */
1011
+ /* Deletecompleted WALs only. */
1007
1012
if (is_arclog && !xlog_is_complete_wal (file ,server_version ))
1008
1013
{
1009
1014
elog (LOG ,"%s() not complete WAL" ,__FUNCTION__ );
@@ -1013,17 +1018,17 @@ delete_old_files(const char *root,
1013
1018
file_num ++ ;
1014
1019
1015
1020
/*
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
1017
1022
* enough number of files newer than the files, delete the file.
1018
1023
*/
1019
- if (file -> mtime >=days_threashold )
1024
+ if (file -> mtime >=days_threshold )
1020
1025
{
1021
1026
elog (LOG ,"%s() %lu is not older than %lu" ,__FUNCTION__ ,
1022
- file -> mtime ,days_threashold );
1027
+ file -> mtime ,days_threshold );
1023
1028
continue ;
1024
1029
}
1025
1030
elog (LOG ,"%s() %lu is older than %lu" ,__FUNCTION__ ,
1026
- file -> mtime ,days_threashold );
1031
+ file -> mtime ,days_threshold );
1027
1032
1028
1033
if (file_num <=keep_files )
1029
1034
{
@@ -1035,7 +1040,7 @@ delete_old_files(const char *root,
1035
1040
if (verbose )
1036
1041
printf (_ ("delete \"%s\"\n" ),file -> path + strlen (root )+ 1 );
1037
1042
1038
- /* delete corresponding backup history file ifany */
1043
+ /* delete corresponding backup history file ifexists */
1039
1044
file = (pgFile * )parray_remove (files ,i );
1040
1045
for (j = parray_num (files )- 1 ;j >=0 ;j -- )
1041
1046
{