From: Eric Bollengier Date: Wed, 20 Feb 2008 08:28:04 +0000 (+0000) Subject: ebl tweak bscan and bextract to handle deleted files (file_index==0) X-Git-Tag: Release-3.0.0~1839 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3b697541c8561c504ccdbb5e41f67ff961f6384f;p=bacula%2Fbacula ebl tweak bscan and bextract to handle deleted files (file_index==0) git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6450 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/patches/testing/project-accurate-backup.patch2 b/bacula/patches/testing/project-accurate-backup.patch2 index 23d90adf4e..01e0c8b8ef 100644 --- a/bacula/patches/testing/project-accurate-backup.patch2 +++ b/bacula/patches/testing/project-accurate-backup.patch2 @@ -62,7 +62,7 @@ Index: src/dird/backup.c /* Commands sent to File daemon */ static char backupcmd[] = "backup\n"; -@@ -96,7 +97,85 @@ +@@ -96,7 +97,93 @@ return true; } @@ -74,15 +74,21 @@ Index: src/dird/backup.c + return 1; + } + -+ if (row[0] > 0) { ++ if (row[0] > 0) { /* discard when file_index == 0 */ + jcr->file_bsock->fsend("%s%s%c%s", row[1], row[2], 0, row[3]); + } + return 0; +} + ++/* Full : do nothing ++ * Differential : get the last full id ++ * Incremental : get the last full + last diff + last incr(s) ids ++ * ++ * TODO: look and merge from ua_restore.c ++ */ +bool db_accurate_get_jobids(JCR *jcr, POOLMEM *jobids) +{ -+ pm_strcpy(jobids, "13"); ++ pm_strcpy(jobids, "42"); + return 1; +} + @@ -107,8 +113,10 @@ Index: src/dird/backup.c + jobids); + db_sql_query(jcr->db, buf, NULL, NULL); + -+ // TODO: compter le nombre de rows -+ jcr->file_bsock->fsend("accurate files=%s\n", edit_uint64(5895, ed2)); /* TODO: change protocol to something like nb= */ ++ bsnprintf(buf, sizeof(buf), "SELECT count(1) FROM btemp2%s",ed1); ++ db_sql_query(jcr->db, buf, NULL, NULL); // TODO: compter le nombre de rows ++ ++ jcr->file_bsock->fsend("accurate files=%s\n", edit_uint64(337969*2, ed2)); + + bsnprintf(buf, sizeof(buf), + "SELECT File.FileIndex, Path.Path, Filename.Name, File.LStat " @@ -148,7 +156,7 @@ Index: src/dird/backup.c * Do a backup of the specified FileSet * * Returns: false on failure -@@ -225,6 +304,14 @@ +@@ -225,6 +312,14 @@ Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); } @@ -163,7 +171,7 @@ Index: src/dird/backup.c /* Send backup command */ fd->fsend(backupcmd); if (!response(jcr, fd, OKbackup, "backup", DISPLAY_ERROR)) { -@@ -234,6 +321,7 @@ +@@ -234,6 +329,7 @@ /* Pickup Job termination data */ stat = wait_for_job_termination(jcr); db_write_batch_file_records(jcr); /* used by bulk batch file insert */ @@ -214,7 +222,7 @@ Index: src/filed/backup.c =================================================================== --- src/filed/backup.c (révision 6443) +++ src/filed/backup.c (copie de travail) -@@ -48,8 +48,213 @@ +@@ -48,8 +48,220 @@ static bool crypto_session_start(JCR *jcr); static void crypto_session_end(JCR *jcr); static bool crypto_session_send(JCR *jcr, BSOCK *sd); @@ -230,10 +238,10 @@ Index: src/filed/backup.c /* + * This function is called for each file seen in fileset. + * -+ * If the file is skipped (attr=NULL), we will check if this ++ * If the file is skipped (saved=false), we will check if this + * file have been backuped before. If not, we decide to backup it. + * -+ * If the file have attr=AAA, we check attr with lstat ++ * If the file have saved=true, we mark it as seen + * + */ +/* TODO: tweak verify code to use the same function */ @@ -256,7 +264,6 @@ Index: src/filed/backup.c + fname = ff_pkt->link; + } + -+ // TODO: check for /path/ and /path/file + elt = (CurFile *) jcr->file_list->lookup(fname); + + if (!elt) { @@ -360,11 +367,12 @@ Index: src/filed/backup.c + break; + } + } -+ *elt->lstat = '\0'; /* mark it as deleted */ ++ *elt->lstat = '\0'; /* mark it as seen */ + Dmsg2(1, "accurate %s = %i\n", fname, stat); + return stat; +} + ++static int deb=0; +int accurate_get_current_file_list_cmd(JCR *jcr) +{ + BSOCK *dir = jcr->dir_bsock; @@ -393,8 +401,15 @@ Index: src/filed/backup.c + memcpy(elt->fname, dir->msg, dir->msglen); + elt->fname[dir->msglen]='\0'; + elt->lstat = elt->fname + len + 1; ++ if ((deb % 1000) == 1) { ++ Dmsg1(1, "deb=%i\n", deb); ++ } ++ if ((deb % 5000) == 1) { ++ jcr->file_list->stats(); ++ } + Dmsg2(100, "hash[%s]=%s\n", elt->fname, elt->lstat); + jcr->file_list->insert(elt->fname, elt); ++ deb++; + } + } + @@ -428,7 +443,7 @@ Index: src/filed/backup.c * Find all the requested files and send them * to the Storage daemon. * -@@ -66,7 +271,6 @@ +@@ -66,7 +278,6 @@ BSOCK *sd; bool ok = true; // TODO landonf: Allow user to specify encryption algorithm @@ -436,7 +451,7 @@ Index: src/filed/backup.c sd = jcr->store_bsock; set_jcr_job_status(jcr, JS_Running); -@@ -134,7 +338,10 @@ +@@ -134,7 +345,10 @@ ok = false; /* error */ set_jcr_job_status(jcr, JS_ErrorTerminated); } @@ -447,7 +462,7 @@ Index: src/filed/backup.c free_pool_memory(jcr->acl_text); stop_heartbeat_monitor(jcr); -@@ -354,9 +561,19 @@ +@@ -354,9 +568,19 @@ } case FT_DIRNOCHG: case FT_NOCHG: @@ -467,7 +482,7 @@ Index: src/filed/backup.c Jmsg(jcr, M_NOTSAVED, 0, _(" Archive file not saved: %s\n"), ff_pkt->fname); return 1; case FT_NOOPEN: { -@@ -1118,6 +1335,9 @@ +@@ -1118,6 +1342,9 @@ } unstrip_path(ff_pkt); @@ -477,7 +492,7 @@ Index: src/filed/backup.c Dmsg2(300, ">stored: attr len=%d: %s\n", sd->msglen, sd->msg); if (!stat) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), -@@ -1128,6 +1348,58 @@ +@@ -1128,6 +1355,58 @@ return true; } @@ -594,6 +609,61 @@ Index: src/filed/job.c /* * We get his UTC since time, then sync the clocks and correct it * to agree with our clock. +Index: src/filed/restore.c +=================================================================== +--- src/filed/restore.c (révision 6443) ++++ src/filed/restore.c (copie de travail) +@@ -320,6 +320,11 @@ + bclose(&rctx.bfd); + } + ++ /* TODO: manage deleted files */ ++ if (file_index == 0) { /* deleted file */ ++ continue; ++ } ++ + /* + * Unpack attributes and do sanity check them + */ +Index: src/stored/bextract.c +=================================================================== +--- src/stored/bextract.c (révision 6443) ++++ src/stored/bextract.c (copie de travail) +@@ -324,6 +324,14 @@ + Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n")); + } + ++ /* handle deleted file ++ */ ++ if (rec->FileIndex == 0) { ++ /* if file is included, remove it ? */ ++ Jmsg(jcr, M_INFO, 0, _("fname=%s is marked as deleted.\n", attr->fname)); ++ break; ++ } ++ + if (attr->file_index != rec->FileIndex) { + Emsg2(M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"), + rec->FileIndex, attr->file_index); +Index: src/stored/bscan.c +=================================================================== +--- src/stored/bscan.c (révision 6443) ++++ src/stored/bscan.c (copie de travail) +@@ -648,6 +648,15 @@ + case STREAM_UNIX_ATTRIBUTES: + case STREAM_UNIX_ATTRIBUTES_EX: + ++ /* handle deleted file ++ */ ++ if (rec->FileIndex == 0) { ++ create_file_attributes_record(db, mjcr, attr->fname, attr->lname, ++ FT_NOSTAT, "", rec); ++ free_jcr(mjcr); ++ break; ++ } ++ + if (!unpack_attributes_record(bjcr, rec->Stream, rec->data, attr)) { + Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n")); + } Index: src/stored/append.c =================================================================== --- src/stored/append.c (révision 6443)