source: MondoRescue/branches/2.2.5/mondo/src/mondorestore/mondo-rstr-compare.c@ 1881

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