Skip to content

Commit 635a4a5

Browse files
committed
Added pgBackupGetPath2()
1 parent d10b05b commit 635a4a5

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

backup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,13 +1676,13 @@ StreamLog(void *arg)
16761676
ctl.synchronous = false;
16771677
ctl.mark_done = false;
16781678
if(ReceiveXlogStream(conn, &ctl) == false)
1679-
elog(ERROR, "Problem in recivexlog");
1679+
elog(ERROR, "Problem in receivexlog");
16801680
}
16811681
#else
16821682
if(ReceiveXlogStream(conn, startpos, starttli, NULL, basedir,
16831683
stop_streaming, standby_message_timeout, NULL,
16841684
false, false) == false)
1685-
elog(ERROR, "Problem in recivexlog");
1685+
elog(ERROR, "Problem in receivexlog");
16861686
#endif
16871687

16881688
PQfinish(conn);

catalog.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,14 +613,32 @@ pgBackupCompareIdDesc(const void *l, const void *r)
613613
*/
614614
void
615615
pgBackupGetPath(const pgBackup *backup, char *path, size_t len, const char *subdir)
616+
{
617+
pgBackupGetPath2(backup, path, len, subdir, NULL);
618+
}
619+
620+
/*
621+
* Construct absolute path of the backup directory.
622+
* Append "subdir1" and "subdir2" to the backup directory.
623+
*/
624+
void
625+
pgBackupGetPath2(const pgBackup *backup, char *path, size_t len,
626+
const char *subdir1, const char *subdir2)
616627
{
617628
char *datetime;
618629

619630
datetime = base36enc(backup->start_time);
620-
if (subdir)
621-
snprintf(path, len, "%s/%s/%s", backup_instance_path, datetime, subdir);
631+
632+
/* If "subdir1" is NULL do not check "subdir2" */
633+
if (!subdir1)
634+
snprintf(path, len, "%s/%s/%s", backup_path, BACKUPS_DIR, datetime);
635+
else if (!subdir2)
636+
snprintf(path, len, "%s/%s/%s/%s", backup_path, BACKUPS_DIR, datetime, subdir1);
637+
/* "subdir1" and "subdir2" is not NULL */
622638
else
623-
snprintf(path, len, "%s/%s", backup_instance_path, datetime);
639+
snprintf(path, len, "%s/%s/%s/%s/%s", backup_path, BACKUPS_DIR,
640+
datetime, subdir1, subdir2);
641+
624642
free(datetime);
625643

626644
make_native_path(path);

pg_probackup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ extern void catalog_lock(void);
338338
extern void pgBackupWriteControl(FILE *out, pgBackup *backup);
339339
extern void pgBackupWriteBackupControlFile(pgBackup *backup);
340340
extern void pgBackupGetPath(const pgBackup *backup, char *path, size_t len, const char *subdir);
341+
extern void pgBackupGetPath2(const pgBackup *backup, char *path, size_t len,
342+
const char *subdir1, const char *subdir2);
341343
extern int pgBackupCreateDir(pgBackup *backup);
342344
extern void pgBackupFree(void *backup);
343345
extern int pgBackupCompareId(const void *f1, const void *f2);

restore.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,9 @@ remove_deleted_files(pgBackup *backup)
373373
{
374374
parray *files;
375375
parray *files_restored;
376-
char database_path[MAXPGPATH];
377376
char filelist_path[MAXPGPATH];
378377
int i;
379378

380-
pgBackupGetPath(backup, database_path, lengthof(database_path), DATABASE_DIR);
381379
pgBackupGetPath(backup, filelist_path, lengthof(filelist_path), DATABASE_FILE_LIST);
382380
/* Read backup's filelist using target database path as base path */
383381
files = dir_read_file_list(pgdata, filelist_path);

0 commit comments

Comments
 (0)