From: Eric Bollengier Date: Tue, 14 Jul 2009 13:49:57 +0000 (+0000) Subject: ebl Implement project 2, about new restore menu X-Git-Tag: Release-3.0.2~80 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fe04cba89598f50e22988a433e6f3233fdd6dc53;p=bacula%2Fbacula ebl Implement project 2, about new restore menu git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8986 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 6dddb21072..8190fa84ee 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -1103,7 +1103,7 @@ bool db_accurate_get_jobids(JCR *jcr, B_DB *mdb, char clientid[50], jobid[50], filesetid[50]; char date[MAX_TIME_LENGTH]; POOL_MEM query(PM_FNAME); - bstrutime(date, sizeof(date), time(NULL) + 1); + bstrutime(date, sizeof(date), jr->JobTDate + 1); jobids[0]='\0'; /* First, find the last good Full backup for this job/client/fileset */ @@ -1134,11 +1134,13 @@ bool db_accurate_get_jobids(JCR *jcr, B_DB *mdb, "WHERE ClientId = %s " "AND Level='D' AND JobStatus IN ('T','W') AND Type='B' " "AND StartTime > (SELECT EndTime FROM btemp3%s ORDER BY EndTime DESC LIMIT 1) " + "AND StartTime < '%s' " "AND FileSet.FileSet= (SELECT FileSet FROM FileSet WHERE FileSetId = %s) " "ORDER BY Job.JobTDate DESC LIMIT 1 ", jobid, clientid, jobid, + date, filesetid); if (!db_sql_query(mdb, query.c_str(), NULL, NULL)) { @@ -1153,11 +1155,13 @@ bool db_accurate_get_jobids(JCR *jcr, B_DB *mdb, "WHERE ClientId = %s " "AND Level='I' AND JobStatus IN ('T','W') AND Type='B' " "AND StartTime > (SELECT EndTime FROM btemp3%s ORDER BY EndTime DESC LIMIT 1) " + "AND StartTime < '%s' " "AND FileSet.FileSet= (SELECT FileSet FROM FileSet WHERE FileSetId = %s) " "ORDER BY Job.JobTDate DESC ", jobid, clientid, jobid, + date, filesetid); if (!db_sql_query(mdb, query.c_str(), NULL, NULL)) { goto bail_out; diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 90a475c6b2..366d9ed370 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -417,6 +417,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) _("Find the JobIds of the most recent backup for a client"), _("Find the JobIds for a backup for a client before a specified time"), _("Enter a list of directories to restore for found JobIds"), + _("Select full restore to a specified JobId"), _("Cancel"), NULL }; @@ -736,11 +737,32 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) } return 2; - case 11: /* Cancel or quit */ + case 11: /* Choose a jobid and select jobs */ + if (!get_cmd(ua, _("Enter JobId to restore: ")) || + !is_an_integer(ua->cmd)) + { + return 0; + } + + memset(&jr, 0, sizeof(JOB_DBR)); + jr.JobId = str_to_int64(ua->cmd); + if (!db_get_job_record(ua->jcr, ua->db, &jr)) { + ua->error_msg(_("Unable to get Job record for JobId=%s: ERR=%s\n"), + ua->cmd, db_strerror(ua->db)); + return 0; + } + jr.JobLevel = L_INCREMENTAL; /* Take Full+Diff+Incr */ + if (!db_accurate_get_jobids(ua->jcr, ua->db, &jr, rx->JobIds)) { + return 0; + } + Dmsg1(30, "Item 12: jobids = %s\n", rx->JobIds); + break; + case 12: /* Cancel or quit */ return 0; } } + memset(&jr, 0, sizeof(JOB_DBR)); POOLMEM *JobIds = get_pool_memory(PM_FNAME); *JobIds = 0; rx->TotalFiles = 0; @@ -1264,7 +1286,7 @@ static bool select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *dat if (!db_sql_query(ua->db, rx->query, NULL, NULL)) { ua->warning_msg("%s\n", db_strerror(ua->db)); } - /* Now update JobTDate to lock onto Differental, if any */ + /* Now update JobTDate to look into Differental, if any */ rx->JobTDate = 0; if (!db_sql_query(ua->db, uar_sel_all_temp, last_full_handler, (void *)rx)) { ua->warning_msg("%s\n", db_strerror(ua->db)); diff --git a/bacula/technotes b/bacula/technotes index 37bad750f1..e37772ca81 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -5,6 +5,8 @@ General: 14Jul09 kes More cleanup of bootstrap 13Jul09 +ebl Implement the project 'restore' menu: enter a JobId, automatically + select dependents kes Send bootstrap directly from DIR to SD kes Create build scripts for Win64 somewhat equilavent to the Win32 ones. 10Jul09