From be25c3e4dbfc6c5b12a342cb260f64f22a1f01ed Mon Sep 17 00:00:00 2001 From: Anastasia Date: Fri, 28 Apr 2017 23:38:18 +0300 Subject: [PATCH] fix check_tablespace_mapping --- dir.c | 3 ++- restore.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dir.c b/dir.c index 6c23cc1c..720cf2e1 100644 --- a/dir.c +++ b/dir.c @@ -616,7 +616,7 @@ 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, PG_TABLESPACE_MAP_FILE); - /* Exit if database/tablespace_map don't exists */ + /* Exit if database/tablespace_map doesn't exist */ if (!fileExists(map_path)) { elog(LOG, "there is no file tablespace_map"); @@ -648,6 +648,7 @@ read_tablespace_map(parray *files, const char *backup_dir) parray_append(files, file); } + parray_qsort(files, pgFileCompareLinked); fclose(fp); } diff --git a/restore.c b/restore.c index 3550a5c9..7cafe8a8 100644 --- a/restore.c +++ b/restore.c @@ -210,6 +210,7 @@ do_restore_or_validate(time_t target_backup_id, /* * Validate backups from base_full_backup to dest_backup. * And restore if subcommand is RESTORE. + * TODO what if we found out that backup is not valid? */ for (i = base_full_backup_index; i >= dest_backup_index; i--) { @@ -270,6 +271,10 @@ restore_backup(pgBackup *backup) pthread_t restore_threads[num_threads]; restore_files_args *restore_threads_args[num_threads]; + if (backup->status != BACKUP_STATUS_OK) + elog(ERROR, "Backup %s cannot be restored because it is not valid", + base36enc(backup->start_time)); + /* confirm block size compatibility */ if (backup->block_size != BLCKSZ) elog(ERROR, @@ -541,7 +546,7 @@ create_directory: /* * Check that all tablespace mapping entries have correct linked directory - * paths. Linked directories should be empty or do not exist. + * paths. Linked directories must be empty or do not exist. * * If tablespace-mapping option is supplied all OLDDIR entries should have * entries in tablespace_map file. @@ -561,7 +566,7 @@ check_tablespace_mapping(pgBackup *backup) pgBackupGetPath(backup, backup_path, lengthof(backup_path), NULL); read_tablespace_map(links, backup_path); - elog(LOG, "check tablespace directories..."); + elog(LOG, "check tablespace directories of backup %s", base36enc(backup->start_time)); /* 1 - OLDDIR should has an entry in links */ for (cell = tablespace_dirs.head; cell; cell = cell->next) @@ -570,7 +575,7 @@ check_tablespace_mapping(pgBackup *backup) if (parray_bsearch(links, tmp_file, pgFileCompareLinked) == NULL) elog(ERROR, "--tablespace-mapping option's old directory " - "has not an entry in tablespace_map file: \"%s\"", + "doesn't have an entry in tablespace_map file: \"%s\"", cell->old_dir); }