Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f6f6789

Browse files
committed
Make it possible for basebackup to backup all snapshots
1 parent bbf67e5 commit f6f6789

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/backend/replication/basebackup.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ static int compareWalFileNames(const void *a, const void *b);
7676
static void throttle(size_t increment);
7777
static bool is_checksummed_file(const char *fullpath, const char *filename);
7878

79+
#define BACKUP_ALL_SNAPSHOTS ((SnapshotId)~0)
80+
7981
/* Was the backup currently in-progress initiated in recovery mode? */
8082
static bool backup_started_in_recovery = false;
8183

@@ -649,6 +651,8 @@ parse_basebackup_options(List *options, basebackup_options *opt)
649651
bool o_snapshot = false;
650652

651653
MemSet(opt, 0, sizeof(*opt));
654+
opt->snapshot = BACKUP_ALL_SNAPSHOTS;
655+
652656
foreach(lopt, options)
653657
{
654658
DefElem *defel = (DefElem *) lfirst(lopt);
@@ -1156,7 +1160,7 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
11561160
}
11571161

11581162
/* Do not backup snapfs files */
1159-
if (is_snapfs_file(de->d_name))
1163+
if (sfs_backend_snapshot != BACKUP_ALL_SNAPSHOTS && is_snapfs_file(de->d_name))
11601164
continue;
11611165

11621166
snprintf(pathbuf, sizeof(pathbuf), "%s/%s", path, de->d_name);
@@ -1395,7 +1399,8 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf
13951399
SnapshotId current_snapshot;
13961400
File file = -1;
13971401

1398-
current_snapshot = sfs_backend_snapshot != SFS_INVALID_SNAPSHOT ? sfs_backend_snapshot : ControlFile->active_snapshot;
1402+
current_snapshot = sfs_backend_snapshot != SFS_INVALID_SNAPSHOT && sfs_backend_snapshot != BACKUP_ALL_SNAPSHOTS
1403+
? sfs_backend_snapshot : ControlFile->active_snapshot;
13991404
if (current_snapshot != SFS_INVALID_SNAPSHOT)
14001405
file = PathNameOpenFile(readfilename, O_RDONLY|PG_BINARY);
14011406

@@ -1562,7 +1567,9 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf
15621567
}
15631568

15641569
/* Remove information about snapshots from control file */
1565-
if (SFS_KEEPING_SNAPSHOT() && strcmp(readfilename, XLOG_CONTROL_FILE) == 0)
1570+
if (SFS_KEEPING_SNAPSHOT()
1571+
&& sfs_backend_snapshot != BACKUP_ALL_SNAPSHOTS
1572+
&& strcmp(readfilename, XLOG_CONTROL_FILE) == 0)
15661573
{
15671574
ControlFileData* ctl = (ControlFileData*)buf;
15681575
ctl->oldest_snapshot = 1;

0 commit comments

Comments
 (0)