source: MondoRescue/branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c@ 2334

Last change on this file since 2334 was 2334, checked in by Bruno Cornec, 15 years ago

r3369@localhost: bruno | 2009-08-18 16:57:27 +0200

  • Transform bout 100 strcpy in dyn. allocation. Quality is improving
  • function figure_out_kernel_path_interactively_if_necessary now return a dynamically allocated string
  • mondoarchive checked with valgrind in text an newt modes
  • Property svn:keywords set to Id
File size: 21.4 KB
RevLine 
[1]1/***************************************************************************
[128]2 cvsid : $Id: mondo-rstr-compare.c 2334 2009-08-18 15:28:18Z bruno $
[1]3***************************************************************************/
4
5#include <pthread.h>
[1930]6#include "my-stuff.h"
[2211]7#include "mr_mem.h"
[1]8#include "../common/mondostructures.h"
9#include "../common/libmondo.h"
10//#include "../../config.h"
11#include "mr-externs.h"
12#include "mondo-rstr-compare.h"
13#include "mondo-restore-EXT.h"
14#include "mondo-rstr-tools-EXT.h"
15
[1316]16extern char *MONDO_LOGFILE;
17
[1645]18/* Reference to global bkpinfo */
19extern struct s_bkpinfo *bkpinfo;
20
[1664]21extern char *g_mountlist_fname;
22
[128]23//static char cvsid[] = "$Id: mondo-rstr-compare.c 2334 2009-08-18 15:28:18Z bruno $";
[1]24
[128]25void popup_changelist_from_file(char *);
[1]26
27
28/**
29 * @addtogroup LLcompareGroup
30 * @{
31 */
32/**
33 * Compare biggiefile number @p bigfileno with the filesystem mounted on @p MNT_RESTORING.
34 * @param bkpinfo The backup information structure. Only used in insist_on_this_cd_number().
35 * @param bigfileno The biggiefile number (starting from 0) to compare.
36 * @note This function uses an MD5 checksum.
37 */
[1645]38int compare_a_biggiefile(long bigfileno)
[1]39{
40
[128]41 FILE *fin;
42 FILE *fout;
[1]43
44 /** needs malloc *******/
[2334]45 char *checksum_ptr = NULL;
46 char *original_cksum_ptr = NULL;
47 char *bigfile_fname_ptr = NULL;
[2211]48 char *tmp_ptr = NULL;
[2296]49 char *command_ptr = NULL;
[1]50
[2334]51 char *checksum, *bigfile_fname, *tmp, *command;
[1]52
[128]53 char *p;
54 int i;
55 int retval = 0;
56
57 struct s_filename_and_lstat_info biggiestruct;
58
59 malloc_string(checksum);
60 malloc_string(bigfile_fname);
61 malloc_string(tmp);
62 malloc_string(command);
63
[1]64 /*********************************************************************
65 * allocate memory clear test sab 16 feb 2003 *
66 *********************************************************************/
[128]67 assert(bkpinfo != NULL);
[1]68 /** end **/
69
[128]70 if (!does_file_exist(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""))) {
71 if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) {
[1645]72 insist_on_this_cd_number((++g_current_media_number));
[128]73 } else {
[2324]74 log_msg(2, "No CD's left. No biggiefiles left. No prob, Bob.");
[128]75 return (0);
76 }
[1]77 }
[128]78 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) {
[2334]79 log_to_screen("Cannot open bigfile %ld (NULL)'s info file", bigfileno + 1);
[128]80 return (1);
[1]81 }
[128]82 fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin);
83 paranoid_fclose(fin);
84
[2334]85 mr_asprintf(checksum_ptr, "%s", biggiestruct.checksum);
86 mr_asprintf(bigfile_fname_ptr, "%s", biggiestruct.filename);
[128]87
88 log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename);
89 log_msg(2, "biggiestruct.checksum = %s", biggiestruct.checksum);
90
91 if (!g_text_mode) {
[2323]92 mr_asprintf(tmp_ptr, "Comparing %s", bigfile_fname_ptr);
[128]93 newtDrawRootText(0, 22, tmp_ptr);
[2211]94 paranoid_free(tmp_ptr);
[128]95 newtRefresh();
[1]96 }
[128]97 if (!checksum[0]) {
98 log_msg(2, "Warning - %s has no checksum", bigfile_fname_ptr);
99 }
100 if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) {
[2296]101 log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname_ptr);
[2334]102 mr_free(bigfile_fname_ptr);
[2296]103 return (1);
[128]104 }
[2296]105
[2332]106 mr_asprintf(command_ptr, "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors", MNT_RESTORING, bigfile_fname_ptr);
[128]107 log_msg(2, command_ptr);
[2296]108 i = system(command_ptr);
109 mr_free(command_ptr);
110
[2323]111 mr_asprintf(tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);
[1321]112 paranoid_system(tmp_ptr);
[2211]113 paranoid_free(tmp_ptr);
114
[2296]115 if (i) {
[128]116 log_OS_error("Warning - command failed");
117 return (1);
118 } else {
119 if (!(fin = fopen("/tmp/md5sum.txt", "r"))) {
120 log_msg(2,
121 "Unable to open /tmp/md5sum.txt; can't get live checksum");
[2334]122 mr_free(bigfile_fname_ptr);
[128]123 return (1);
124 } else {
[2334]125 mr_getline(original_cksum_ptr, fin);
[128]126 paranoid_fclose(fin);
[2334]127 p = strchr(original_cksum_ptr, ' ');
[128]128 if (p) {
129 *p = '\0';
130 }
131 }
132 }
[2323]133 mr_asprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname_ptr);
[2334]134 if ((original_cksum_ptr != NULL) && (strcmp(checksum_ptr, original_cksum_ptr) == 0)) {
[2211]135 mr_strcat(tmp_ptr, " ... OK");
[128]136 } else {
[2211]137 mr_strcat(tmp_ptr, "... changed");
[128]138 retval++;
139 }
[2334]140 mr_free(checksum_ptr);
141 mr_free(original_cksum_ptr);
142
[128]143 log_msg(1, tmp_ptr);
[2211]144 paranoid_free(tmp_ptr);
145
[128]146 if (retval) {
[1747]147 if (!(fout = fopen(MONDO_CACHE"/changed.txt", "a"))) {
[128]148 fatal_error("Cannot openout changed.txt");
149 }
150 fprintf(fout, "%s\n", bigfile_fname_ptr);
151 paranoid_fclose(fout);
152 }
[2334]153 mr_free(bigfile_fname_ptr);
[1]154
[128]155 paranoid_free(bigfile_fname);
156 paranoid_free(checksum);
157 paranoid_free(command);
158 paranoid_free(tmp);
[1]159
[128]160 return (retval);
[1]161}
162
163/**************************************************************************
164 *END_COMPARE_A_BIGGIEFILE *
165 **************************************************************************/
166
167
168/**
169 * Compare all biggiefiles in the backup.
170 * @return 0 for success, nonzero for failure.
171 */
[1645]172int compare_all_biggiefiles()
[1]173{
[128]174 int retval = 0;
175 int res;
176 long noof_biggiefiles, bigfileno = 0;
[2296]177 char *tmp = NULL;
[1]178
[128]179 log_msg(1, "Comparing biggiefiles");
180
181 if (length_of_file(BIGGIELIST) < 6) {
182 log_msg(1,
183 "OK, really teeny-tiny biggielist; not comparing biggiefiles");
184 return (0);
185 }
186 noof_biggiefiles = count_lines_in_file(BIGGIELIST);
187 if (noof_biggiefiles <= 0) {
188 log_msg(1, "OK, no biggiefiles; not comparing biggiefiles");
189 return (0);
190 }
191 mvaddstr_and_log_it(g_currentY, 0,
[541]192 "Comparing large files ");
193 open_progress_form("Comparing large files",
194 "I am now comparing the large files",
195 "against the filesystem. Please wait.", "",
[128]196 noof_biggiefiles);
197 for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) {
[2332]198 mr_asprintf(tmp, "Comparing big file #%ld", bigfileno + 1);
[128]199 log_msg(1, tmp);
200 update_progress_form(tmp);
[2296]201 mr_free(tmp);
202
[1645]203 res = compare_a_biggiefile(bigfileno);
[128]204 retval += res;
205 g_current_progress++;
206 }
207 close_progress_form();
208 return (0);
209 if (retval) {
[541]210 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
[128]211 } else {
[541]212 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
[128]213 }
214 return (retval);
[1]215}
[128]216
[1]217/**************************************************************************
218 *END_COMPARE_ALL_BIGGIEFILES *
219 **************************************************************************/
220
221
222/**
223 * Compare afioball @p tarball_fname against the filesystem.
224 * You must be chdir()ed to the directory where the filesystem is mounted
225 * before you call this function.
226 * @param tarball_fname The filename of the tarball to compare.
227 * @param current_tarball_number The fileset number contained in @p tarball_fname.
228 * @return 0 for success, nonzero for failure.
229 */
[128]230int compare_a_tarball(char *tarball_fname, int current_tarball_number)
[1]231{
[128]232 int retval = 0;
233 int res;
234 long noof_lines;
235 long archiver_errors;
236 bool use_star;
237
[1]238 /*** needs malloc *********/
[2296]239 char *command = NULL;
240 char *tmp = NULL;
[2211]241 char *archiver_exe = NULL;
[2332]242 char *tmp1 = NULL;
[2296]243 char *filelist_name = NULL;
244 char *logfile = NULL;
245 char *compressor_exe = NULL;
[1]246
[128]247 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
248 assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
[2332]249 mr_asprintf(filelist_name, MNT_CDROM "/archives/filelist.%d", current_tarball_number);
[128]250 noof_lines = count_lines_in_file(filelist_name);
[2296]251 mr_free(filelist_name);
[128]252
253 if (strstr(tarball_fname, ".bz2")) {
[2332]254 mr_asprintf(compressor_exe, "bzip2");
[998]255 } else if (strstr(tarball_fname, ".gz")) {
[2332]256 mr_asprintf(compressor_exe, "gzip");
[128]257 } else if (strstr(tarball_fname, ".lzo")) {
[2332]258 mr_asprintf(compressor_exe, "lzop");
[1]259 }
[128]260
261 if (use_star) {
[2323]262 mr_asprintf(archiver_exe, "star");
[128]263 } else {
[2323]264 mr_asprintf(archiver_exe, "afio");
[1]265 }
[128]266
[2296]267 if (compressor_exe) {
[2332]268 tmp1 = find_home_of_exe(compressor_exe);
269 if (!tmp1) {
270 mr_free(tmp1);
[2296]271 mr_free(compressor_exe);
272 mr_free(archiver_exe);
[128]273 fatal_error("(compare_a_tarball) Compression program missing");
274 }
[2332]275 mr_free(tmp1);
276
[2296]277 if (use_star) {
[128]278 if (!strcmp(compressor_exe, "bzip2")) {
[2211]279 mr_strcat(archiver_exe, " -bz");
[128]280 } else {
[2296]281 mr_free(compressor_exe);
282 mr_free(archiver_exe);
283 fatal_error("(compare_a_tarball) Please use only bzip2 with star");
[128]284 }
[2296]285 } else {
286 // afio
287 mr_free(compressor_exe);
[2332]288 mr_asprintf(tmp, "%s", compressor_exe);
289 mr_asprintf(compressor_exe, "-P %s -Z", tmp);
[2296]290 mr_free(tmp);
[128]291 }
292 }
[1]293
294#ifdef __FreeBSD__
295#define BUFSIZE 512L
296#else
297#define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE
298#endif
[2332]299 mr_asprintf(logfile, "/tmp/afio.log.%d", current_tarball_number);
[2296]300
301 if (use_star) {
302 // doesn't use compressor_exe
[2332]303 mr_asprintf(command, "%s -diff H=star file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile);
[128]304 } else {
[2332]305 mr_asprintf(command, "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", archiver_exe, TAPE_BLOCK_SIZE, BUFSIZE, compressor_exe, tarball_fname, logfile, logfile);
[128]306 }
[2296]307 mr_free(compressor_exe);
[2211]308 paranoid_free(archiver_exe);
309
[1]310#undef BUFSIZE
311
[128]312 res = system(command);
313 retval += res;
314 if (res) {
315 log_OS_error(command);
[2296]316 log_msg(2, "Warning - afio returned error = %d", res);
[128]317 }
[2296]318 mr_free(command);
319
[128]320 if (length_of_file(logfile) > 5) {
[2332]321 mr_asprintf(command, "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", logfile);
[128]322 system(command);
[2296]323 mr_free(command);
324
[128]325 archiver_errors = count_lines_in_file(logfile);
326 } else {
327 archiver_errors = 0;
328 }
329 if (archiver_errors) {
[2296]330 log_msg(1, "%ld difference%c in fileset #%d ", archiver_errors, (archiver_errors != 1) ? 's' : ' ', current_tarball_number);
[128]331 }
332 unlink(logfile);
[2296]333 mr_free(logfile);
334
[128]335 return (retval);
[1]336}
[128]337
[1]338/**************************************************************************
339 *END_COMPARE_A_TARBALL *
340 **************************************************************************/
341
342
343/**
344 * Compare all afioballs in this backup.
345 * @param bkpinfo The backup media structure. Passed to other functions.
346 * @return 0 for success, nonzero for failure.
347 */
[1645]348int compare_all_tarballs()
[1]349{
[128]350 int retval = 0;
351 int res;
352 int current_tarball_number = 0;
[1]353
354 /** needs malloc **********/
355
[2334]356 char *tarball_fname = NULL;
357 char *progress_str = NULL;
[2325]358 char *tmp = NULL;
[2242]359 char *mds = NULL;
[128]360 long max_val;
[1]361
[128]362 assert(bkpinfo != NULL);
[541]363 mvaddstr_and_log_it(g_currentY, 0, "Comparing archives");
[2325]364 tmp = read_cfg_var(g_mondo_cfg_file, "last-filelist-number");
365 max_val = atol(tmp);
366 mr_free(tmp);
[2296]367
[2242]368 mds = media_descriptor_string(bkpinfo->backup_media_type);
[2332]369 mr_asprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
[128]370
[541]371 open_progress_form("Comparing files",
372 "Comparing tarballs against filesystem.",
373 "Please wait. This may take some time.",
[128]374 progress_str, max_val);
375
376 log_to_screen(progress_str);
377
378 for (;;) {
[1645]379 insist_on_this_cd_number(g_current_media_number);
[128]380 update_progress_form(progress_str);
[2332]381 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number);
[128]382
383 if (!does_file_exist(tarball_fname)) {
[2296]384 mr_free(tarball_fname);
[2332]385 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzo", current_tarball_number);
[128]386 }
387 if (!does_file_exist(tarball_fname)) {
[2296]388 mr_free(tarball_fname);
[2332]389 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.gz", current_tarball_number);
[1630]390 }
391 if (!does_file_exist(tarball_fname)) {
[2296]392 mr_free(tarball_fname);
[2332]393 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.", current_tarball_number);
[128]394 }
395 if (!does_file_exist(tarball_fname)) {
[2296]396 mr_free(tarball_fname);
[2332]397 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.star.bz2", current_tarball_number);
[128]398 }
399 if (!does_file_exist(tarball_fname)) {
[2296]400 mr_free(tarball_fname);
[2332]401 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.star.", current_tarball_number);
[128]402 }
403 if (!does_file_exist(tarball_fname)) {
404 if (!does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST") ||
405 system("find " MNT_CDROM
406 "/archives/slice* > /dev/null 2> /dev/null")
407 == 0) {
408 log_msg(2, "OK, I think I'm done with tarballs...");
[2296]409 mr_free(tarball_fname);
[128]410 break;
411 }
412 log_msg(2, "OK, I think it's time for another CD...");
413 g_current_media_number++;
[2296]414
415 mr_free(progress_str);
[2332]416 mr_asprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
[128]417 log_to_screen(progress_str);
418 } else {
419 res = compare_a_tarball(tarball_fname, current_tarball_number);
420
421 g_current_progress++;
422 current_tarball_number++;
423 }
[2296]424 mr_free(tarball_fname);
[1]425 }
[2296]426 mr_free(progress_str);
[2242]427 mr_free(mds);
428
[128]429 close_progress_form();
430 if (retval) {
[541]431 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
[128]432 } else {
[541]433 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
[1]434 }
[128]435 return (retval);
[1]436}
[128]437
[1]438/**************************************************************************
439 *END_COMPARE_ALL_TARBALLS *
440 **************************************************************************/
441
442/* @} - end LLcompareGroup */
443
444
445/**
446 * @addtogroup compareGroup
447 * @{
448 */
449/**
450 * Compare all data on a CD-R/CD-RW/DVD/ISO/NFS-based backup.
451 * @param bkpinfo The backup information structure. Passed to other functions.
452 * @return 0 for success, nonzero for failure.
453 */
[1645]454int compare_to_CD()
[1]455{
456 /** needs malloc *********/
[2296]457 char *tmp = NULL;
458 char *cwd, *new;
459 char *command = NULL;
[128]460 int resA = 0;
461 int resB = 0;
462 long noof_changed_files;
[1]463
[128]464 malloc_string(cwd);
465 malloc_string(new);
[1]466
[128]467 assert(bkpinfo != NULL);
468
469 getcwd(cwd, MAX_STR_LEN - 1);
470 chdir(bkpinfo->restore_path);
471 getcwd(new, MAX_STR_LEN - 1);
[1645]472 insist_on_this_cd_number(g_current_media_number);
[1747]473 unlink(MONDO_CACHE"/changed.txt");
[128]474
[1645]475 resA = compare_all_tarballs();
476 resB = compare_all_biggiefiles();
[128]477 chdir(cwd);
[1747]478 noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt");
[128]479 if (noof_changed_files) {
[2332]480 mr_asprintf(tmp, "%ld files do not match the backup ", noof_changed_files);
[128]481 log_to_screen(tmp);
[2296]482 mr_free(tmp);
483
[2332]484 mr_asprintf(command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE);
[128]485 paranoid_system(command);
[2296]486 mr_free(command);
[128]487 } else {
[2332]488 mr_asprintf(tmp, "All files match the backup ");
[128]489 mvaddstr_and_log_it(g_currentY++, 0, tmp);
490 log_to_screen(tmp);
[2296]491 mr_free(tmp);
[128]492 }
493
494 paranoid_free(cwd);
495 paranoid_free(new);
496
497 return (resA + resB);
[1]498}
499
500/**************************************************************************
501 *END_COMPARE_TO_CD *
502 **************************************************************************/
503
504
505
506
507/**
508 * Compare all data in the user's backup.
509 * This function will mount filesystems, compare afioballs and biggiefiles,
510 * and show the user the differences.
511 * @param bkpinfo The backup information structure. Passed to other functions.
512 * @param mountlist The mountlist containing partitions to mount.
513 * @param raidlist The raidlist containing the user's RAID devices.
514 * @return The number of errors/differences found.
515 */
516int
[1645]517compare_mode(struct mountlist_itself *mountlist,
[128]518 struct raidlist_itself *raidlist)
[1]519{
[128]520 int retval = 0;
[1664]521 int res = 0;
[128]522 long q;
[2296]523 char *tmp = NULL;
[1585]524 char *new;
525 char *cwd;
[1]526
[1585]527 malloc_string(new);
528 malloc_string(cwd);
[128]529
[1]530 /**************************************************************************
531 * also deletes tmp/filelist.full & tmp/biggielist.txt _and_ tries to *
532 * restore them from start of tape, if available *
533 **************************************************************************/
[128]534 assert(bkpinfo != NULL);
535 assert(mountlist != NULL);
536 assert(raidlist != NULL);
[1]537
[1645]538 while (get_cfg_file_from_archive()) {
[128]539 if (!ask_me_yes_or_no
[541]540 ("Failed to find config file/archives. Choose another source?"))
[128]541 {
542 fatal_error("Unable to find config file/archives. Aborting.");
543 }
[1645]544 interactively_obtain_media_parameters_from_user(FALSE);
[128]545 }
[1]546
[1645]547 read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
[1664]548
549 /* edit_mountlist if wanted */
[2230]550 log_it("About to edit mountlist");
[1664]551 if (g_text_mode) {
552 save_mountlist_to_disk(mountlist, g_mountlist_fname);
[2332]553 mr_asprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);
[1664]554 res = system(tmp);
[2296]555 mr_free(tmp);
556
[1664]557 load_mountlist(mountlist, g_mountlist_fname);
558 } else {
559 res = edit_mountlist(g_mountlist_fname, mountlist, raidlist);
560 }
[2230]561 log_it("Finished editing mountlist");
[1664]562 if (res) {
563 paranoid_MR_finish(1);
564 }
565 save_mountlist_to_disk(mountlist, g_mountlist_fname);
566 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
567
[128]568 g_current_media_number = 1;
[541]569 mvaddstr_and_log_it(1, 30, "Comparing Automatically");
[2230]570 log_it("Pre-MAD");
[128]571 retval = mount_all_devices(mountlist, FALSE);
[2230]572 log_it("Post-MAD");
[128]573 if (retval) {
574 unmount_all_devices(mountlist);
575 return (retval);
576 }
577 if (bkpinfo->backup_media_type == tape
578 || bkpinfo->backup_media_type == udev) {
[1645]579 retval += compare_to_tape();
[128]580 } else if (bkpinfo->backup_media_type == cdstream) {
[1645]581 retval += compare_to_cdstream();
[128]582 } else {
[1645]583 retval += compare_to_CD();
[128]584 }
585 if (retval) {
586 mvaddstr_and_log_it(g_currentY++,
587 0,
[541]588 "Warning - differences found during the compare phase");
[128]589 }
[1]590
[1747]591 if (count_lines_in_file(MONDO_CACHE"/changed.txt") > 0) {
[128]592 mvaddstr_and_log_it(g_currentY++, 0,
[541]593 "Differences found while files were being compared.");
[1747]594 streamline_changes_file(MONDO_CACHE"/changed.files", MONDO_CACHE"/changed.txt");
595 if (count_lines_in_file(MONDO_CACHE"/changed.files") <= 0) {
[128]596 mvaddstr_and_log_it(g_currentY++, 0,
[541]597 "...but they were logfiles and temporary files. Your archives are fine.");
[128]598 log_to_screen
[541]599 ("The differences were logfiles and temporary files. Your archives are fine.");
[128]600 } else {
[1747]601 q = count_lines_in_file(MONDO_CACHE"/changed.files");
[2332]602 mr_asprintf(tmp, "%ld significant difference%s found.", q, (q != 1) ? "s" : "");
[128]603 mvaddstr_and_log_it(g_currentY++, 0, tmp);
604 log_to_screen(tmp);
[2296]605 mr_free(tmp);
[1]606
[2332]607 mr_asprintf(tmp, "Type 'less /tmp/changed.files' for a list of non-matching files");
[128]608 mvaddstr_and_log_it(g_currentY++, 0, tmp);
609 log_to_screen(tmp);
[2296]610 mr_free(tmp);
[1]611
[128]612 log_msg(2, "calling popup_changelist_from_file()");
[1585]613 getcwd(cwd, MAX_STR_LEN - 1);
614 chdir(bkpinfo->restore_path);
615 getcwd(new, MAX_STR_LEN - 1);
[1747]616 popup_changelist_from_file(MONDO_CACHE"/changed.files");
[1585]617 chdir(cwd);
[128]618 log_msg(2, "Returning from popup_changelist_from_file()");
619 }
620 } else {
621 log_to_screen
[541]622 ("No significant differences were found. Your backup is perfect.");
[1]623 }
[1585]624 retval += unmount_all_devices(mountlist);
625
[128]626 kill_petris();
[1585]627 paranoid_free(new);
628 paranoid_free(cwd);
[128]629 return (retval);
[1]630}
631
632/**************************************************************************
633 *END_COMPARE_MODE *
634 **************************************************************************/
635
636/**
637 * Compare all data on a cdstream-based backup.
638 * @param bkpinfo The backup information structure. Fields used:
639 * - @c bkpinfo->disaster_recovery
640 * - @c bkpinfo->media_device
641 * - @c bkpinfo->restore_path
642 * @return 0 for success, nonzero for failure.
643 */
[1645]644int compare_to_cdstream()
[1]645{
[128]646 int res;
[1]647
648 /** needs malloc **/
[2296]649 char *dir;
650 char *command = NULL;
[1]651
[128]652 assert(bkpinfo != NULL);
653 malloc_string(dir);
654 getcwd(dir, MAX_STR_LEN);
655 chdir(bkpinfo->restore_path);
[1]656
[2327]657 mr_asprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path);
[128]658 run_program_and_log_output(command, FALSE);
[2296]659 mr_free(command);
660
[128]661 mvaddstr_and_log_it(g_currentY,
[541]662 0, "Verifying archives against filesystem");
[1]663
[2325]664 mr_free(bkpinfo->media_device);
[2321]665 if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
[2325]666 mr_asprintf(bkpinfo->media_device, "%s", last_line_of_file("/tmp/CDROM-LIVES-HERE"));
[128]667 } else {
[2325]668 bkpinfo->media_device = find_cdrom_device(FALSE);
[128]669 }
[1645]670 res = verify_tape_backups();
[128]671 chdir(dir);
[1747]672 if (length_of_file(MONDO_CACHE"/changed.txt") > 2
673 && length_of_file(MONDO_CACHE"/changed.files") > 2) {
[128]674 log_msg(0,
[1747]675 "Type 'less "MONDO_CACHE"/changed.files' to see which files don't match the archives");
[128]676 log_msg(2, "Calling popup_changelist_from_file()");
[1747]677 popup_changelist_from_file(MONDO_CACHE"/changed.files");
[128]678 log_msg(2, "Returned from popup_changelist_from_file()");
679 }
680
[541]681 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
[128]682 paranoid_free(dir);
683 return (res);
[1]684}
[128]685
[1]686/**************************************************************************
687 *END_COMPARE_CD_STREAM *
688 **************************************************************************/
689
690
691/**
692 * Compare all data on a tape-based backup.
693 * @param bkpinfo The backup information structure. Field used: @c bkpinfo->restore_path.
694 * @return 0 for success, nonzero for failure.
695 */
696/**************************************************************************
697 * F@COMPARE_TO_TAPE() *
698 * compare_to_tape() - gots me?? *
699 * *
700 * returns: int *
701 **************************************************************************/
[1645]702int compare_to_tape()
[1]703{
[128]704 int res;
[2296]705 char *dir;
706 char *command = NULL;
[1]707
[128]708 assert(bkpinfo != NULL);
709 malloc_string(dir);
710
711 getcwd(dir, MAX_STR_LEN);
712 chdir(bkpinfo->restore_path);
[2332]713 mr_asprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path);
[128]714 run_program_and_log_output(command, FALSE);
[2296]715 mr_free(command);
716
[128]717 mvaddstr_and_log_it(g_currentY,
[541]718 0, "Verifying archives against filesystem");
[1645]719 res = verify_tape_backups();
[128]720 chdir(dir);
721 if (res) {
[541]722 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
[128]723 } else {
[541]724 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
[128]725 }
726 paranoid_free(dir);
727 return (res);
[1]728}
729
730/**************************************************************************
731 *END_COMPARE_TO_TAPE *
732 **************************************************************************/
733
734/* @} - end compareGroup */
Note: See TracBrowser for help on using the repository browser.