Skip to content

Commit be25c3e

Browse files
committed
fix check_tablespace_mapping
1 parent 88754a7 commit be25c3e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

dir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ read_tablespace_map(parray *files, const char *backup_dir)
616616
join_path_components(db_path, backup_dir, DATABASE_DIR);
617617
join_path_components(map_path, db_path, PG_TABLESPACE_MAP_FILE);
618618

619-
/* Exit if database/tablespace_map don't exists */
619+
/* Exit if database/tablespace_map doesn't exist */
620620
if (!fileExists(map_path))
621621
{
622622
elog(LOG, "there is no file tablespace_map");
@@ -648,6 +648,7 @@ read_tablespace_map(parray *files, const char *backup_dir)
648648
parray_append(files, file);
649649
}
650650

651+
parray_qsort(files, pgFileCompareLinked);
651652
fclose(fp);
652653
}
653654

restore.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ do_restore_or_validate(time_t target_backup_id,
210210
/*
211211
* Validate backups from base_full_backup to dest_backup.
212212
* And restore if subcommand is RESTORE.
213+
* TODO what if we found out that backup is not valid?
213214
*/
214215
for (i = base_full_backup_index; i >= dest_backup_index; i--)
215216
{
@@ -270,6 +271,10 @@ restore_backup(pgBackup *backup)
270271
pthread_t restore_threads[num_threads];
271272
restore_files_args *restore_threads_args[num_threads];
272273

274+
if (backup->status != BACKUP_STATUS_OK)
275+
elog(ERROR, "Backup %s cannot be restored because it is not valid",
276+
base36enc(backup->start_time));
277+
273278
/* confirm block size compatibility */
274279
if (backup->block_size != BLCKSZ)
275280
elog(ERROR,
@@ -541,7 +546,7 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
541546

542547
/*
543548
* Check that all tablespace mapping entries have correct linked directory
544-
* paths. Linked directories should be empty or do not exist.
549+
* paths. Linked directories must be empty or do not exist.
545550
*
546551
* If tablespace-mapping option is supplied all OLDDIR entries should have
547552
* entries in tablespace_map file.
@@ -561,7 +566,7 @@ check_tablespace_mapping(pgBackup *backup)
561566
pgBackupGetPath(backup, backup_path, lengthof(backup_path), NULL);
562567
read_tablespace_map(links, backup_path);
563568

564-
elog(LOG, "check tablespace directories...");
569+
elog(LOG, "check tablespace directories of backup %s", base36enc(backup->start_time));
565570

566571
/* 1 - OLDDIR should has an entry in links */
567572
for (cell = tablespace_dirs.head; cell; cell = cell->next)
@@ -570,7 +575,7 @@ check_tablespace_mapping(pgBackup *backup)
570575

571576
if (parray_bsearch(links, tmp_file, pgFileCompareLinked) == NULL)
572577
elog(ERROR, "--tablespace-mapping option's old directory "
573-
"has not an entry in tablespace_map file: \"%s\"",
578+
"doesn't have an entry in tablespace_map file: \"%s\"",
574579
cell->old_dir);
575580
}
576581

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