Skip to content

Commit 5bc8d45

Browse files
author
Artur Zakirov
committed
Do not create tablespace_map.txt file
1 parent b8edd16 commit 5bc8d45

File tree

4 files changed

+4
-86
lines changed

4 files changed

+4
-86
lines changed

backup.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
9696
{
9797
size_t i;
9898
parray *prev_files = NULL; /* file list of previous database backup */
99-
char current_path[MAXPGPATH];
10099
char database_path[MAXPGPATH];
101100
char dst_backup_path[MAXPGPATH];
102101
char label[1024];
@@ -193,11 +192,6 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
193192
}
194193
}
195194

196-
pgBackupGetPath(&current, current_path, lengthof(current_path), NULL);
197-
/* Make tablespace_map.txt file on standby */
198-
if (from_replica)
199-
create_tablespace_map(pgdata, current_path);
200-
201195
/*
202196
* To take differential backup, the file list of the last completed database
203197
* backup is needed.

dir.c

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -550,80 +550,6 @@ list_data_directories(parray *files, const char *path, bool is_root,
550550
path, strerror(prev_errno));
551551
}
552552

553-
/*
554-
* List symlinks of tablespaces. Symlinks locate on pg_tblspc directory.
555-
*/
556-
void
557-
create_tablespace_map(const char *pg_data, const char *backup_dir)
558-
{
559-
char path[MAXPGPATH];
560-
FILE *fp = NULL;
561-
DIR *dir;
562-
struct dirent *dent;
563-
int prev_errno;
564-
565-
join_path_components(path, pg_data, PG_TBLSPC_DIR);
566-
567-
dir = opendir(path);
568-
if (dir == NULL)
569-
elog(ERROR, "cannot open directory \"%s\": %s", path, strerror(errno));
570-
571-
errno = 0;
572-
while ((dent = readdir(dir)))
573-
{
574-
char child[MAXPGPATH];
575-
struct stat st;
576-
577-
/* skip entries point current dir or parent dir */
578-
if (strcmp(dent->d_name, ".") == 0 ||
579-
strcmp(dent->d_name, "..") == 0)
580-
continue;
581-
582-
join_path_components(child, path, dent->d_name);
583-
584-
/* Check if file is symlink */
585-
if (lstat(child, &st) == -1)
586-
elog(ERROR, "cannot stat file \"%s\": %s", child, strerror(errno));
587-
588-
if (S_ISLNK(st.st_mode))
589-
{
590-
ssize_t len;
591-
char linked[MAXPGPATH];
592-
593-
len = readlink(child, linked, sizeof(linked));
594-
if (len < 0)
595-
elog(ERROR, "cannot read link \"%s\": %s", child,
596-
strerror(errno));
597-
if (len >= sizeof(linked))
598-
elog(ERROR, "symbolic link \"%s\" target is too long\n", child);
599-
600-
linked[len] = '\0';
601-
602-
/* Open file if this is first symlink */
603-
if (fp == NULL)
604-
{
605-
char map_path[MAXPGPATH];
606-
607-
join_path_components(map_path, backup_dir, TABLESPACE_MAP_FILE);
608-
fp = pgut_fopen(map_path, "wt", false);
609-
}
610-
611-
fprintf(fp, "%s %s", dent->d_name, linked);
612-
}
613-
}
614-
615-
prev_errno = errno;
616-
617-
closedir(dir);
618-
if (fp)
619-
fclose(fp);
620-
621-
/* If we had error during readdir() */
622-
if (prev_errno && prev_errno != ENOENT)
623-
elog(ERROR, "cannot read directory \"%s\": %s",
624-
path, strerror(prev_errno));
625-
}
626-
627553
/*
628554
* Read names of symbolik names of tablespaces with links to directories from
629555
* tablespace_map or tablespace_map.txt.
@@ -639,12 +565,11 @@ read_tablespace_map(parray *files, const char *backup_dir)
639565
join_path_components(db_path, backup_dir, DATABASE_DIR);
640566
join_path_components(map_path, db_path, "tablespace_map");
641567

642-
/* Exit if database/tablespace_map and tablespace_map.txt don't exists */
568+
/* Exit if database/tablespace_map don't exists */
643569
if (!fileExists(map_path))
644570
{
645-
join_path_components(map_path, backup_dir, TABLESPACE_MAP_FILE);
646-
if (!fileExists(map_path))
647-
return;
571+
elog(LOG, "there is no file tablespace_map");
572+
return;
648573
}
649574

650575
fp = fopen(map_path, "rt");

pg_probackup.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#define BACKUP_CATALOG_CONF_FILE "pg_probackup.conf"
4343
#define MKDIRS_SH_FILE "mkdirs.sh"
4444
#define DATABASE_FILE_LIST "file_database.txt"
45-
#define TABLESPACE_MAP_FILE "tablespace_map.txt"
4645
#define PG_BACKUP_LABEL_FILE "backup_label"
4746
#define PG_BLACK_LIST "black_list"
4847

@@ -317,7 +316,6 @@ extern void dir_list_file(parray *files, const char *root, bool exclude,
317316
extern void list_data_directories(parray *files, const char *path,
318317
bool is_root, bool exclude);
319318

320-
extern void create_tablespace_map(const char *pg_data, const char *backup_dir);
321319
extern void read_tablespace_map(parray *files, const char *backup_dir);
322320

323321
extern void print_file_list(FILE *out, const parray *files, const char *root);

tests/restore_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ def test_restore_with_tablespace_mapping_12(self):
524524
self.restore_pb(node))
525525

526526
# 3 - Restore using tablespace-mapping
527+
node.cleanup()
527528
tblspc_path_new = path.join(node.base_dir, "tblspc_new")
528529
self.assertIn(six.b("INFO: restore complete."),
529530
self.restore_pb(node,

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