mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-11-24 08:52:38 +02:00
Do not create tablespace_map.txt file
This commit is contained in:
parent
b8edd16145
commit
5bc8d459e0
6
backup.c
6
backup.c
@ -96,7 +96,6 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
|
||||
{
|
||||
size_t i;
|
||||
parray *prev_files = NULL; /* file list of previous database backup */
|
||||
char current_path[MAXPGPATH];
|
||||
char database_path[MAXPGPATH];
|
||||
char dst_backup_path[MAXPGPATH];
|
||||
char label[1024];
|
||||
@ -193,11 +192,6 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
|
||||
}
|
||||
}
|
||||
|
||||
pgBackupGetPath(¤t, current_path, lengthof(current_path), NULL);
|
||||
/* Make tablespace_map.txt file on standby */
|
||||
if (from_replica)
|
||||
create_tablespace_map(pgdata, current_path);
|
||||
|
||||
/*
|
||||
* To take differential backup, the file list of the last completed database
|
||||
* backup is needed.
|
||||
|
81
dir.c
81
dir.c
@ -550,80 +550,6 @@ list_data_directories(parray *files, const char *path, bool is_root,
|
||||
path, strerror(prev_errno));
|
||||
}
|
||||
|
||||
/*
|
||||
* List symlinks of tablespaces. Symlinks locate on pg_tblspc directory.
|
||||
*/
|
||||
void
|
||||
create_tablespace_map(const char *pg_data, const char *backup_dir)
|
||||
{
|
||||
char path[MAXPGPATH];
|
||||
FILE *fp = NULL;
|
||||
DIR *dir;
|
||||
struct dirent *dent;
|
||||
int prev_errno;
|
||||
|
||||
join_path_components(path, pg_data, PG_TBLSPC_DIR);
|
||||
|
||||
dir = opendir(path);
|
||||
if (dir == NULL)
|
||||
elog(ERROR, "cannot open directory \"%s\": %s", path, strerror(errno));
|
||||
|
||||
errno = 0;
|
||||
while ((dent = readdir(dir)))
|
||||
{
|
||||
char child[MAXPGPATH];
|
||||
struct stat st;
|
||||
|
||||
/* skip entries point current dir or parent dir */
|
||||
if (strcmp(dent->d_name, ".") == 0 ||
|
||||
strcmp(dent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
join_path_components(child, path, dent->d_name);
|
||||
|
||||
/* Check if file is symlink */
|
||||
if (lstat(child, &st) == -1)
|
||||
elog(ERROR, "cannot stat file \"%s\": %s", child, strerror(errno));
|
||||
|
||||
if (S_ISLNK(st.st_mode))
|
||||
{
|
||||
ssize_t len;
|
||||
char linked[MAXPGPATH];
|
||||
|
||||
len = readlink(child, linked, sizeof(linked));
|
||||
if (len < 0)
|
||||
elog(ERROR, "cannot read link \"%s\": %s", child,
|
||||
strerror(errno));
|
||||
if (len >= sizeof(linked))
|
||||
elog(ERROR, "symbolic link \"%s\" target is too long\n", child);
|
||||
|
||||
linked[len] = '\0';
|
||||
|
||||
/* Open file if this is first symlink */
|
||||
if (fp == NULL)
|
||||
{
|
||||
char map_path[MAXPGPATH];
|
||||
|
||||
join_path_components(map_path, backup_dir, TABLESPACE_MAP_FILE);
|
||||
fp = pgut_fopen(map_path, "wt", false);
|
||||
}
|
||||
|
||||
fprintf(fp, "%s %s", dent->d_name, linked);
|
||||
}
|
||||
}
|
||||
|
||||
prev_errno = errno;
|
||||
|
||||
closedir(dir);
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
|
||||
/* If we had error during readdir() */
|
||||
if (prev_errno && prev_errno != ENOENT)
|
||||
elog(ERROR, "cannot read directory \"%s\": %s",
|
||||
path, strerror(prev_errno));
|
||||
}
|
||||
|
||||
/*
|
||||
* Read names of symbolik names of tablespaces with links to directories from
|
||||
* tablespace_map or tablespace_map.txt.
|
||||
@ -639,12 +565,11 @@ read_tablespace_map(parray *files, const char *backup_dir)
|
||||
join_path_components(db_path, backup_dir, DATABASE_DIR);
|
||||
join_path_components(map_path, db_path, "tablespace_map");
|
||||
|
||||
/* Exit if database/tablespace_map and tablespace_map.txt don't exists */
|
||||
/* Exit if database/tablespace_map don't exists */
|
||||
if (!fileExists(map_path))
|
||||
{
|
||||
join_path_components(map_path, backup_dir, TABLESPACE_MAP_FILE);
|
||||
if (!fileExists(map_path))
|
||||
return;
|
||||
elog(LOG, "there is no file tablespace_map");
|
||||
return;
|
||||
}
|
||||
|
||||
fp = fopen(map_path, "rt");
|
||||
|
@ -42,7 +42,6 @@
|
||||
#define BACKUP_CATALOG_CONF_FILE "pg_probackup.conf"
|
||||
#define MKDIRS_SH_FILE "mkdirs.sh"
|
||||
#define DATABASE_FILE_LIST "file_database.txt"
|
||||
#define TABLESPACE_MAP_FILE "tablespace_map.txt"
|
||||
#define PG_BACKUP_LABEL_FILE "backup_label"
|
||||
#define PG_BLACK_LIST "black_list"
|
||||
|
||||
@ -317,7 +316,6 @@ extern void dir_list_file(parray *files, const char *root, bool exclude,
|
||||
extern void list_data_directories(parray *files, const char *path,
|
||||
bool is_root, bool exclude);
|
||||
|
||||
extern void create_tablespace_map(const char *pg_data, const char *backup_dir);
|
||||
extern void read_tablespace_map(parray *files, const char *backup_dir);
|
||||
|
||||
extern void print_file_list(FILE *out, const parray *files, const char *root);
|
||||
|
@ -524,6 +524,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.restore_pb(node))
|
||||
|
||||
# 3 - Restore using tablespace-mapping
|
||||
node.cleanup()
|
||||
tblspc_path_new = path.join(node.base_dir, "tblspc_new")
|
||||
self.assertIn(six.b("INFO: restore complete."),
|
||||
self.restore_pb(node,
|
||||
|
Loading…
Reference in New Issue
Block a user