Skip to content

Commit af29599

Browse files
committed
Merge master Version 1.1.11
2 parents ab1965d + e3a3737 commit af29599

36 files changed

+3732
-1711
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
/env
2929
/tests/__pycache__/
3030
/tests/tmp_dirs/
31+
/tests/*pyc
3132

3233
# Extra files
3334
/datapagemap.c

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ OBJS = backup.o \
66
delete.o \
77
dir.o \
88
fetch.o \
9+
help.o \
910
init.o \
1011
parray.o \
1112
pg_probackup.o \

data.c

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void
5656
backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
5757
BlockNumber blknum, BlockNumber nblocks,
5858
FILE *in, FILE *out,
59-
pg_crc32 *crc)
59+
pg_crc32 *crc, int *n_skipped)
6060
{
6161
BackupPageHeader header;
6262
off_t offset;
@@ -134,7 +134,10 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
134134
if (!XLogRecPtrIsInvalid(prev_backup_start_lsn)
135135
&& !XLogRecPtrIsInvalid(page_lsn)
136136
&& page_lsn < prev_backup_start_lsn)
137+
{
138+
*n_skipped += 1;
137139
return;
140+
}
138141

139142
/* Verify checksum */
140143
if(current.checksum_version && !is_zero_page)
@@ -195,6 +198,8 @@ backup_data_file(const char *from_root, const char *to_root,
195198
FILE *out;
196199
BlockNumber blknum = 0;
197200
BlockNumber nblocks = 0;
201+
int n_blocks_skipped = 0;
202+
int n_blocks_read = 0;
198203

199204
/* reset size summary */
200205
file->read_size = 0;
@@ -253,26 +258,24 @@ backup_data_file(const char *from_root, const char *to_root,
253258
if (file->pagemap.bitmapsize == 0)
254259
{
255260
for (blknum = 0; blknum < nblocks; blknum++)
261+
{
256262
backup_data_page(file, prev_backup_start_lsn, blknum,
257-
nblocks, in, out, &(file->crc));
263+
nblocks, in, out, &(file->crc), &n_blocks_skipped);
264+
n_blocks_read++;
265+
}
258266
}
259267
else
260268
{
261269
datapagemap_iterator_t *iter;
262270
iter = datapagemap_iterate(&file->pagemap);
263271
while (datapagemap_next(iter, &blknum))
272+
{
264273
backup_data_page(file, prev_backup_start_lsn, blknum,
265-
nblocks, in, out, &(file->crc));
274+
nblocks, in, out, &(file->crc), &n_blocks_skipped);
275+
n_blocks_read++;
276+
}
266277

267278
pg_free(iter);
268-
/*
269-
* If we have pagemap then file can't be a zero size.
270-
* Otherwise, we will clear the last file.
271-
* Increase read_size to delete after.
272-
* TODO rewrite this code
273-
*/
274-
if (file->read_size == 0)
275-
file->read_size++;
276279
}
277280

278281
/* update file permission */
@@ -294,8 +297,11 @@ backup_data_file(const char *from_root, const char *to_root,
294297
if (file->read_size == 0)
295298
file->is_datafile = false;
296299

297-
/* We do not backup if all pages skipped. */
298-
if (file->write_size == 0 && file->read_size > 0)
300+
/*
301+
* If we have pagemap then file can't be a zero size.
302+
* Otherwise, we will clear the last file.
303+
*/
304+
if (n_blocks_read == n_blocks_skipped)
299305
{
300306
if (remove(to_path) == -1)
301307
elog(ERROR, "cannot remove file \"%s\": %s", to_path,
@@ -406,7 +412,7 @@ restore_file_partly(const char *from_root,const char *to_root, pgFile *file)
406412
fclose(out);
407413
}
408414

409-
static void
415+
void
410416
restore_compressed_file(const char *from_root,
411417
const char *to_root,
412418
pgFile *file)
@@ -436,20 +442,6 @@ restore_data_file(const char *from_root,
436442
BackupPageHeader header;
437443
BlockNumber blknum;
438444

439-
if (!file->is_datafile)
440-
{
441-
/*
442-
* If the file is not a datafile and not compressed file,
443-
* just copy it.
444-
*/
445-
if (file->generation == -1)
446-
copy_file(from_root, to_root, file);
447-
else
448-
restore_compressed_file(from_root, to_root, file);
449-
450-
return;
451-
}
452-
453445
/* open backup mode file for read */
454446
in = fopen(file->path, "r");
455447
if (in == NULL)

delete.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ do_retention_purge(void)
207207
parray_free(backup_list);
208208

209209
if (backup_deleted)
210-
elog(INFO, "purging finished");
210+
elog(INFO, "Purging finished");
211211
else
212-
elog(INFO, "no one backup was deleted by retention policy");
212+
elog(INFO, "Nothing to delete by retention policy");
213213

214214
return 0;
215215
}

help.c

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* help.c
4+
*
5+
* Portions Copyright (c) 2017-2017, Postgres Professional
6+
*
7+
*-------------------------------------------------------------------------
8+
*/
9+
#include "pg_probackup.h"
10+
11+
static void help_init(void);
12+
static void help_backup(void);
13+
static void help_restore(void);
14+
static void help_validate(void);
15+
static void help_show(void);
16+
static void help_delete(void);
17+
static void help_set_config(void);
18+
static void help_show_config(void);
19+
20+
void
21+
help_command(char *command)
22+
{
23+
if (strcmp(command, "init") == 0)
24+
help_init();
25+
else if (strcmp(command, "backup") == 0)
26+
help_backup();
27+
else if (strcmp(command, "restore") == 0)
28+
help_restore();
29+
else if (strcmp(command, "validate") == 0)
30+
help_validate();
31+
else if (strcmp(command, "show") == 0)
32+
help_show();
33+
else if (strcmp(command, "delete") == 0)
34+
help_delete();
35+
else if (strcmp(command, "set-config") == 0)
36+
help_set_config();
37+
else if (strcmp(command, "show-config") == 0)
38+
help_show_config();
39+
else if (strcmp(command, "--help") == 0
40+
|| strcmp(command, "help") == 0
41+
|| strcmp(command, "-?") == 0
42+
|| strcmp(command, "--version") == 0
43+
|| strcmp(command, "version") == 0
44+
|| strcmp(command, "-V") == 0)
45+
printf(_("No help page for \"%s\" command. Try pg_probackup help\n"), command);
46+
else
47+
printf(_("Unknown command. Try pg_probackup help\n"));
48+
exit(0);
49+
}
50+
51+
void
52+
help_pg_probackup(void)
53+
{
54+
printf(_("\n%s - utility to manage backup/recovery of PostgreSQL database.\n\n"), PROGRAM_NAME);
55+
56+
printf(_(" %s help [COMMAND]\n"), PROGRAM_NAME);
57+
58+
printf(_("\n %s version\n"), PROGRAM_NAME);
59+
60+
printf(_("\n %s init -B backup-path -D pgdata-dir\n"), PROGRAM_NAME);
61+
62+
printf(_("\n %s set-config -B backup-dir\n"), PROGRAM_NAME);
63+
printf(_(" [-d dbname] [-h host] [-p port] [-U username]\n"));
64+
printf(_(" [--retention-redundancy=retention-redundancy]]\n"));
65+
printf(_(" [--retention-window=retention-window]\n"));
66+
67+
printf(_("\n %s show-config -B backup-dir\n"), PROGRAM_NAME);
68+
69+
printf(_("\n %s backup -B backup-path -b backup-mode\n"), PROGRAM_NAME);
70+
printf(_(" [-D pgdata-dir] [-C] [--stream [-S slot-name]] [--backup-pg-log]\n"));
71+
printf(_(" [-j num-threads] [--archive-timeout=archive-timeout]\n"));
72+
printf(_(" [--progress] [-q] [-v] [--delete-expired]\n"));
73+
printf(_(" [-d dbname] [-h host] [-p port] [-U username]\n"));
74+
75+
printf(_("\n %s restore -B backup-dir\n"), PROGRAM_NAME);
76+
printf(_(" [-D pgdata-dir] [-i backup-id] [--progress] [-q] [-v]\n"));
77+
printf(_(" [--time=time|--xid=xid [--inclusive=boolean]]\n"));
78+
printf(_(" [--timeline=timeline] [-T OLDDIR=NEWDIR]\n"));
79+
80+
printf(_("\n %s validate -B backup-dir\n"), PROGRAM_NAME);
81+
printf(_(" [-D pgdata-dir] [-i backup-id] [--progress] [-q] [-v]\n"));
82+
printf(_(" [--time=time|--xid=xid [--inclusive=boolean]]\n"));
83+
printf(_(" [--timeline=timeline]\n"));
84+
85+
printf(_("\n %s show -B backup-dir\n"), PROGRAM_NAME);
86+
printf(_(" [-i backup-id]\n"));
87+
88+
printf(_("\n %s delete -B backup-dir\n"), PROGRAM_NAME);
89+
printf(_(" [--wal] [-i backup-id | --expired]\n"));
90+
91+
if ((PROGRAM_URL || PROGRAM_EMAIL))
92+
{
93+
printf("\n");
94+
if (PROGRAM_URL)
95+
printf("Read the website for details. <%s>\n", PROGRAM_URL);
96+
if (PROGRAM_EMAIL)
97+
printf("Report bugs to <%s>.\n", PROGRAM_EMAIL);
98+
}
99+
exit(0);
100+
}
101+
102+
static void
103+
help_init(void)
104+
{
105+
printf(_("%s init -B backup-path -D pgdata-dir\n\n"), PROGRAM_NAME);
106+
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
107+
printf(_(" -D, --pgdata=pgdata-dir location of the database storage area\n"));
108+
}
109+
110+
static void
111+
help_backup(void)
112+
{
113+
printf(_("%s backup -B backup-path -b backup-mode\n"), PROGRAM_NAME);
114+
printf(_(" [-D pgdata-dir] [-C] [--stream [-S slot-name]] [--backup-pg-log]\n"));
115+
printf(_(" [-j num-threads] [--archive-timeout=archive-timeout]\n"));
116+
printf(_(" [--progress] [-q] [-v] [--delete-expired]\n"));
117+
printf(_(" [-d dbname] [-h host] [-p port] [-U username]\n\n"));
118+
119+
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
120+
printf(_(" -b, --backup-mode=backup-mode backup mode=FULL|PAGE|PTRACK\n"));
121+
printf(_(" -D, --pgdata=pgdata-dir location of the database storage area\n"));
122+
printf(_(" -C, --smooth-checkpoint do smooth checkpoint before backup\n"));
123+
printf(_(" --stream stream the transaction log and include it in the backup\n"));
124+
printf(_(" --archive-timeout wait timeout for WAL segment archiving\n"));
125+
printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
126+
printf(_(" --backup-pg-log backup of pg_log directory\n"));
127+
printf(_(" -j, --threads=NUM number of parallel threads\n"));
128+
printf(_(" --progress show progress\n"));
129+
printf(_(" -q, --quiet don't write any messages\n"));
130+
printf(_(" -v, --verbose verbose mode\n"));
131+
printf(_(" --delete-expired delete backups expired according to current\n"));
132+
printf(_(" retention policy after successful backup completion\n"));
133+
134+
printf(_("\n Connection options:\n"));
135+
printf(_(" -d, --dbname=DBNAME database to connect\n"));
136+
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
137+
printf(_(" -p, --port=PORT database server port\n"));
138+
printf(_(" -U, --username=USERNAME user name to connect as\n"));
139+
}
140+
141+
static void
142+
help_restore(void)
143+
{
144+
printf(_("%s restore -B backup-dir\n"), PROGRAM_NAME);
145+
printf(_(" [-D pgdata-dir] [-i backup-id] [--progress] [-q] [-v]\n"));
146+
printf(_(" [--time=time|--xid=xid [--inclusive=boolean]]\n"));
147+
printf(_(" [--timeline=timeline] [-T OLDDIR=NEWDIR]\n\n"));
148+
149+
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
150+
printf(_(" -D, --pgdata=pgdata-dir location of the database storage area\n"));
151+
printf(_(" -i, --backup-id=backup-id backup to restore\n"));
152+
153+
printf(_(" --progress show progress\n"));
154+
printf(_(" -q, --quiet don't write any messages\n"));
155+
printf(_(" -v, --verbose verbose mode\n"));
156+
printf(_(" --time=time time stamp up to which recovery will proceed\n"));
157+
printf(_(" --xid=xid transaction ID up to which recovery will proceed\n"));
158+
printf(_(" --inclusive=boolean whether we stop just after the recovery target\n"));
159+
printf(_(" --timeline=timeline recovering into a particular timeline\n"));
160+
printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n"));
161+
printf(_(" relocate the tablespace from directory OLDDIR to NEWDIR\n"));
162+
}
163+
164+
static void
165+
help_validate(void)
166+
{
167+
printf(_("%s validate -B backup-dir\n"), PROGRAM_NAME);
168+
printf(_(" [-D pgdata-dir] [-i backup-id] [--progress] [-q] [-v]\n"));
169+
printf(_(" [--time=time|--xid=xid [--inclusive=boolean]]\n"));
170+
printf(_(" [--timeline=timeline]\n\n"));
171+
172+
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
173+
printf(_(" -D, --pgdata=pgdata-dir location of the database storage area\n"));
174+
printf(_(" -i, --backup-id=backup-id backup to validate\n"));
175+
176+
printf(_(" --progress show progress\n"));
177+
printf(_(" -q, --quiet don't write any messages\n"));
178+
printf(_(" -v, --verbose verbose mode\n"));
179+
printf(_(" --time=time time stamp up to which recovery will proceed\n"));
180+
printf(_(" --xid=xid transaction ID up to which recovery will proceed\n"));
181+
printf(_(" --inclusive=boolean whether we stop just after the recovery target\n"));
182+
printf(_(" --timeline=timeline recovering into a particular timeline\n"));
183+
}
184+
185+
static void
186+
help_show(void)
187+
{
188+
printf(_("%s show -B backup-dir\n"), PROGRAM_NAME);
189+
printf(_(" [-i backup-id]\n\n"));
190+
191+
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
192+
printf(_(" -i, --backup-id=backup-id show info about specific backups\n"));
193+
}
194+
195+
static void
196+
help_delete(void)
197+
{
198+
printf(_("%s delete -B backup-dir\n"), PROGRAM_NAME);
199+
printf(_(" [--wal] [-i backup-id | --expired]\n\n"));
200+
201+
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
202+
printf(_(" --wal remove unnecessary wal files\n"));
203+
printf(_(" -i, --backup-id=backup-id backup to delete\n"));
204+
printf(_(" --expired delete backups expired according to current\n"));
205+
printf(_(" retention policy\n"));
206+
}
207+
208+
static void
209+
help_set_config(void)
210+
{
211+
printf(_("%s set-config -B backup-dir\n"), PROGRAM_NAME);
212+
printf(_(" [-d dbname] [-h host] [-p port] [-U username]\n"));
213+
printf(_(" [--retention-redundancy=retention-redundancy]]\n"));
214+
printf(_(" [--retention-window=retention-window]\n\n"));
215+
216+
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
217+
218+
printf(_("\n Connection options:\n"));
219+
printf(_(" -d, --dbname=DBNAME database to connect\n"));
220+
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
221+
printf(_(" -p, --port=PORT database server port\n"));
222+
printf(_(" -U, --username=USERNAME user name to connect as\n"));
223+
224+
printf(_("\n Retention options:\n"));
225+
printf(_(" --retention-redundancy=retention-redundancy\n"));
226+
printf(_(" number of full backups to keep\n"));
227+
printf(_(" --retention-window=retention-window\n"));
228+
printf(_(" number of days of recoverability\n"));
229+
230+
}
231+
232+
static void
233+
help_show_config(void)
234+
{
235+
printf(_("%s show-config -B backup-dir\n\n"), PROGRAM_NAME);
236+
237+
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
238+
}

parsexlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ validate_wal(pgBackup *backup,
249249
if (!xlogexists)
250250
elog(WARNING, "WAL segment \"%s\" is absent", xlogfpath);
251251
else if (xlogreadfd != -1)
252-
elog(WARNING, "error was occured during reading WAL segment \"%s\"",
253-
xlogfpath);
252+
elog(ERROR, "Possible WAL CORRUPTION."
253+
"Error has occured during reading WAL segment \"%s\"", xlogfpath);
254254
}
255255

256256
if (!got_endpoint)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy