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

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

r3338@localhost: bruno | 2009-08-11 23:03:30 +0200
bkpinfo->zip_suffix, bkpinfo->image_devs and bkpinfo->restore_path are now allocated dynmically

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