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

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