mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-02-03 14:01:57 +02:00
Try fixing restore command.
This commit is contained in:
parent
3e49dd17c5
commit
bd01446a9d
10
pg_arman.c
10
pg_arman.c
@ -106,7 +106,8 @@ main(int argc, char *argv[])
|
||||
cmd = argv[i];
|
||||
if(strcmp(cmd, "show") != 0 &&
|
||||
strcmp(cmd, "validate") != 0 &&
|
||||
strcmp(cmd, "delete") != 0)
|
||||
strcmp(cmd, "delete") != 0 &&
|
||||
strcmp(cmd, "restore") != 0)
|
||||
break;
|
||||
} else if (backup_id_string == NULL)
|
||||
backup_id_string = argv[i];
|
||||
@ -122,7 +123,12 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (backup_id_string != NULL)
|
||||
{
|
||||
backup_id = base36dec(backup_id_string);
|
||||
if (backup_id == 0) {
|
||||
elog(ERROR, "wrong ID");
|
||||
}
|
||||
}
|
||||
|
||||
/* Read default configuration from file. */
|
||||
if (backup_path)
|
||||
@ -189,7 +195,7 @@ main(int argc, char *argv[])
|
||||
do_validate(current.start_time);
|
||||
}
|
||||
else if (pg_strcasecmp(cmd, "restore") == 0)
|
||||
return do_restore(target_time, target_xid,
|
||||
return do_restore(backup_id, target_time, target_xid,
|
||||
target_inclusive, target_tli);
|
||||
else if (pg_strcasecmp(cmd, "show") == 0)
|
||||
return do_show(backup_id, show_all);
|
||||
|
@ -32,13 +32,13 @@
|
||||
/* Directory/File names */
|
||||
#define DATABASE_DIR "database"
|
||||
#define RESTORE_WORK_DIR "backup"
|
||||
#define PG_XLOG_DIR "pg_xlog"
|
||||
#define PG_XLOG_DIR "pg_xlog"
|
||||
#define PG_TBLSPC_DIR "pg_tblspc"
|
||||
#define BACKUP_INI_FILE "backup.ini"
|
||||
#define PG_RMAN_INI_FILE "pg_arman.ini"
|
||||
#define MKDIRS_SH_FILE "mkdirs.sh"
|
||||
#define DATABASE_FILE_LIST "file_database.txt"
|
||||
#define PG_BACKUP_LABEL_FILE "backup_label"
|
||||
#define PG_BACKUP_LABEL_FILE "backup_label"
|
||||
#define PG_BLACK_LIST "black_list"
|
||||
|
||||
/* Direcotry/File permission */
|
||||
@ -214,7 +214,8 @@ extern void process_block_change(ForkNumber forknum, RelFileNode rnode,
|
||||
BlockNumber blkno);
|
||||
|
||||
/* in restore.c */
|
||||
extern int do_restore(const char *target_time,
|
||||
extern int do_restore(time_t backup_id,
|
||||
const char *target_time,
|
||||
const char *target_xid,
|
||||
const char *target_inclusive,
|
||||
TimeLineID target_tli);
|
||||
|
25
restore.c
25
restore.c
@ -45,7 +45,8 @@ static void restore_files(void *arg);
|
||||
|
||||
|
||||
int
|
||||
do_restore(const char *target_time,
|
||||
do_restore(time_t backup_id,
|
||||
const char *target_time,
|
||||
const char *target_xid,
|
||||
const char *target_inclusive,
|
||||
TimeLineID target_tli)
|
||||
@ -62,6 +63,7 @@ do_restore(const char *target_time,
|
||||
parray *timelines;
|
||||
pgRecoveryTarget *rt = NULL;
|
||||
XLogRecPtr need_lsn;
|
||||
bool backup_id_found = false;
|
||||
|
||||
/* PGDATA and ARCLOG_PATH are always required */
|
||||
if (pgdata == NULL)
|
||||
@ -134,12 +136,21 @@ do_restore(const char *target_time,
|
||||
{
|
||||
base_backup = (pgBackup *) parray_get(backups, i);
|
||||
|
||||
if (backup_id && base_backup->start_time > backup_id)
|
||||
continue;
|
||||
|
||||
if (backup_id == base_backup->start_time &&
|
||||
base_backup->status == BACKUP_STATUS_OK
|
||||
)
|
||||
backup_id_found = true;
|
||||
|
||||
if (base_backup->backup_mode < BACKUP_MODE_FULL ||
|
||||
base_backup->status != BACKUP_STATUS_OK)
|
||||
continue;
|
||||
|
||||
if (satisfy_timeline(timelines, base_backup) &&
|
||||
satisfy_recovery_target(base_backup, rt))
|
||||
satisfy_recovery_target(base_backup, rt) &&
|
||||
(backup_id_found || backup_id == 0))
|
||||
goto base_backup_found;
|
||||
}
|
||||
/* no full backup found, cannot restore */
|
||||
@ -167,6 +178,9 @@ base_backup_found:
|
||||
backup->tli != base_backup->tli)
|
||||
continue;
|
||||
|
||||
if (backup->backup_mode == BACKUP_MODE_FULL)
|
||||
break;
|
||||
|
||||
/* use database backup only */
|
||||
if (backup->backup_mode != BACKUP_MODE_DIFF_PAGE &&
|
||||
backup->backup_mode != BACKUP_MODE_DIFF_PTRACK)
|
||||
@ -462,11 +476,14 @@ create_recovery_conf(const char *target_time,
|
||||
|
||||
if (target_time)
|
||||
fprintf(fp, "recovery_target_time = '%s'\n", target_time);
|
||||
if (target_xid)
|
||||
else if (target_xid)
|
||||
fprintf(fp, "recovery_target_xid = '%s'\n", target_xid);
|
||||
else
|
||||
fprintf(fp, "recovery_target = 'immediate'\n");
|
||||
|
||||
if (target_inclusive)
|
||||
fprintf(fp, "recovery_target_inclusive = '%s'\n", target_inclusive);
|
||||
/*fprintf(fp, "recovery_target = 'immediate'\n");*/
|
||||
|
||||
fprintf(fp, "recovery_target_timeline = '%u'\n", target_tli);
|
||||
|
||||
fclose(fp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user