source: MondoRescue/trunk/mondo/mondo/mondorestore/mondo-rstr-compare.c@ 276

Last change on this file since 276 was 276, checked in by bcornec, 18 years ago

merge -r274:275 $SVN_M/branches/2.06

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