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

Last change on this file since 1645 was 1645, checked in by Bruno Cornec, 17 years ago

Render bkpinfo global (potential issue on thread, but should not be a problem as that structure is indeed static during archive)
Should solve the tmpdir issue from previous rev.
May still not compile

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