source: MondoRescue/branches/2.2.2/mondo/src/mondorestore/mondo-rstr-compare.c@ 1321

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

Still fixing other similar changes

  • 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 1321 2007-04-16 19:11:19Z 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//static char cvsid[] = "$Id: mondo-rstr-compare.c 1321 2007-04-16 19:11:19Z bruno $";
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",
167 MNT_RESTORING, bigfile_fname_ptr);
168 }
169 log_msg(2, command_ptr);
170 sprintf(tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);
171 paranoid_system(tmp_ptr);
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, ".gz")) {
322 strcpy(compressor_exe, "gzip");
323 } else if (strstr(tarball_fname, ".lzo")) {
324 strcpy(compressor_exe, "lzop");
325 } else {
326 compressor_exe[0] = '\0';
327 }
328
329 if (use_star) {
330 strcpy(archiver_exe, "star");
331 } else {
332 strcpy(archiver_exe, "afio");
333 }
334
335 if (compressor_exe[0]) {
336 strcpy(tmp, compressor_exe);
337 if (!find_home_of_exe(tmp)) {
338 fatal_error("(compare_a_tarball) Compression program missing");
339 }
340 if (use_star) // star
341 {
342 if (!strcmp(compressor_exe, "bzip2")) {
343 strcat(archiver_exe, " -bz");
344 } else {
345 fatal_error
346 ("(compare_a_tarball) Please use only bzip2 with star");
347 }
348 } else // afio
349 {
350 sprintf(compressor_exe, "-P %s -Z", tmp);
351 }
352 }
353// star -diff H=star -bz file=....
354
355#ifdef __FreeBSD__
356#define BUFSIZE 512L
357#else
358#define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE
359#endif
360 if (use_star) // doesn't use compressor_exe
361 {
362 sprintf(command,
363 "%s -diff H=star file=%s >> %s 2>> %s",
364 archiver_exe, tarball_fname, logfile, logfile);
365 } else {
366 sprintf(command,
367 "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s",
368 archiver_exe,
369 TAPE_BLOCK_SIZE,
370 BUFSIZE, compressor_exe, tarball_fname, logfile, logfile);
371 }
372#undef BUFSIZE
373
374 res = system(command);
375 retval += res;
376 if (res) {
377 log_OS_error(command);
378 sprintf(tmp, "Warning - afio returned error = %d", res);
379 }
380 if (length_of_file(logfile) > 5) {
381 sprintf(command,
382 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> /tmp/changed.txt",
383 logfile);
384 system(command);
385 archiver_errors = count_lines_in_file(logfile);
386 } else {
387 archiver_errors = 0;
388 }
389 sprintf(tmp, "%ld difference%c in fileset #%d ",
390 archiver_errors, (archiver_errors != 1) ? 's' : ' ',
391 current_tarball_number);
392 if (archiver_errors) {
393 sprintf(tmp,
394 "Differences found while processing fileset #%d ",
395 current_tarball_number);
396 log_msg(1, tmp);
397 }
398 unlink(logfile);
399 paranoid_free(command);
400 paranoid_free(tmp);
401 paranoid_free(filelist_name);
402 paranoid_free(logfile);
403 malloc_string(archiver_exe);
404 malloc_string(compressor_exe);
405 return (retval);
406}
407
408/**************************************************************************
409 *END_COMPARE_A_TARBALL *
410 **************************************************************************/
411
412
413/**
414 * Compare all afioballs in this backup.
415 * @param bkpinfo The backup media structure. Passed to other functions.
416 * @return 0 for success, nonzero for failure.
417 */
418int compare_all_tarballs(struct s_bkpinfo *bkpinfo)
419{
420 int retval = 0;
421 int res;
422 int current_tarball_number = 0;
423
424 /** needs malloc **********/
425
426 char *tarball_fname, *progress_str, *tmp;
427 long max_val;
428
429 malloc_string(tarball_fname);
430 malloc_string(progress_str);
431 malloc_string(tmp);
432
433 assert(bkpinfo != NULL);
434 mvaddstr_and_log_it(g_currentY, 0, "Comparing archives");
435 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
436
437 max_val = atol(tmp);
438 sprintf(progress_str, "Comparing with %s #%d ",
439 media_descriptor_string(bkpinfo->backup_media_type),
440 g_current_media_number);
441
442 open_progress_form("Comparing files",
443 "Comparing tarballs against filesystem.",
444 "Please wait. This may take some time.",
445 progress_str, max_val);
446
447 log_to_screen(progress_str);
448
449 for (;;) {
450 insist_on_this_cd_number(bkpinfo, g_current_media_number);
451 update_progress_form(progress_str);
452 sprintf(tarball_fname,
453 MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number);
454
455 if (!does_file_exist(tarball_fname)) {
456 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",
457 current_tarball_number);
458 }
459 if (!does_file_exist(tarball_fname)) {
460 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.",
461 current_tarball_number);
462 }
463 if (!does_file_exist(tarball_fname)) {
464 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.bz2",
465 current_tarball_number);
466 }
467 if (!does_file_exist(tarball_fname)) {
468 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.",
469 current_tarball_number);
470 }
471 if (!does_file_exist(tarball_fname)) {
472 if (!does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST") ||
473 system("find " MNT_CDROM
474 "/archives/slice* > /dev/null 2> /dev/null")
475 == 0) {
476 log_msg(2, "OK, I think I'm done with tarballs...");
477 break;
478 }
479 log_msg(2, "OK, I think it's time for another CD...");
480 g_current_media_number++;
481 sprintf(progress_str, "Comparing with %s #%d ",
482 media_descriptor_string(bkpinfo->backup_media_type),
483 g_current_media_number);
484 log_to_screen(progress_str);
485 } else {
486 res = compare_a_tarball(tarball_fname, current_tarball_number);
487
488 g_current_progress++;
489 current_tarball_number++;
490 }
491 }
492 close_progress_form();
493 if (retval) {
494 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
495 } else {
496 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
497 }
498 paranoid_free(tarball_fname);
499 paranoid_free(progress_str);
500 paranoid_free(tmp);
501 return (retval);
502}
503
504/**************************************************************************
505 *END_COMPARE_ALL_TARBALLS *
506 **************************************************************************/
507
508/* @} - end LLcompareGroup */
509
510
511/**
512 * @addtogroup compareGroup
513 * @{
514 */
515/**
516 * Compare all data on a CD-R/CD-RW/DVD/ISO/NFS-based backup.
517 * @param bkpinfo The backup information structure. Passed to other functions.
518 * @return 0 for success, nonzero for failure.
519 */
520int compare_to_CD(struct s_bkpinfo *bkpinfo)
521{
522 /** needs malloc *********/
523 char *tmp, *cwd, *new, *command;
524 int resA = 0;
525 int resB = 0;
526 long noof_changed_files;
527
528 malloc_string(tmp);
529 malloc_string(cwd);
530 malloc_string(new);
531 malloc_string(command);
532
533 assert(bkpinfo != NULL);
534
535 getcwd(cwd, MAX_STR_LEN - 1);
536 chdir(bkpinfo->restore_path);
537 getcwd(new, MAX_STR_LEN - 1);
538 sprintf(tmp, "new path is %s", new);
539 insist_on_this_cd_number(bkpinfo, g_current_media_number);
540 unlink("/tmp/changed.txt");
541
542 resA = compare_all_tarballs(bkpinfo);
543 resB = compare_all_biggiefiles(bkpinfo);
544 chdir(cwd);
545 noof_changed_files = count_lines_in_file("/tmp/changed.txt");
546 if (noof_changed_files) {
547 sprintf(tmp, "%ld files do not match the backup ",
548 noof_changed_files);
549 // mvaddstr_and_log_it( g_currentY++, 0, tmp );
550 log_to_screen(tmp);
551 sprintf(command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE);
552 paranoid_system(command);
553 } else {
554 sprintf(tmp, "All files match the backup ");
555 mvaddstr_and_log_it(g_currentY++, 0, tmp);
556 log_to_screen(tmp);
557 }
558
559 paranoid_free(tmp);
560 paranoid_free(cwd);
561 paranoid_free(new);
562 paranoid_free(command);
563
564 return (resA + resB);
565}
566
567/**************************************************************************
568 *END_COMPARE_TO_CD *
569 **************************************************************************/
570
571
572
573
574/**
575 * Compare all data in the user's backup.
576 * This function will mount filesystems, compare afioballs and biggiefiles,
577 * and show the user the differences.
578 * @param bkpinfo The backup information structure. Passed to other functions.
579 * @param mountlist The mountlist containing partitions to mount.
580 * @param raidlist The raidlist containing the user's RAID devices.
581 * @return The number of errors/differences found.
582 */
583int
584compare_mode(struct s_bkpinfo *bkpinfo,
585 struct mountlist_itself *mountlist,
586 struct raidlist_itself *raidlist)
587{
588 int retval = 0;
589 long q;
590 char *tmp;
591
592 malloc_string(tmp);
593
594 /**************************************************************************
595 * also deletes tmp/filelist.full & tmp/biggielist.txt _and_ tries to *
596 * restore them from start of tape, if available *
597 **************************************************************************/
598 assert(bkpinfo != NULL);
599 assert(mountlist != NULL);
600 assert(raidlist != NULL);
601
602 while (get_cfg_file_from_archive(bkpinfo)) {
603 if (!ask_me_yes_or_no
604 ("Failed to find config file/archives. Choose another source?"))
605 {
606 fatal_error("Unable to find config file/archives. Aborting.");
607 }
608 interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
609 }
610
611 read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);
612 g_current_media_number = 1;
613 mvaddstr_and_log_it(1, 30, "Comparing Automatically");
614 iamhere("Pre-MAD");
615 retval = mount_all_devices(mountlist, FALSE);
616 iamhere("Post-MAD");
617 if (retval) {
618 unmount_all_devices(mountlist);
619 return (retval);
620 }
621 if (bkpinfo->backup_media_type == tape
622 || bkpinfo->backup_media_type == udev) {
623 retval += compare_to_tape(bkpinfo);
624 } else if (bkpinfo->backup_media_type == cdstream) {
625 retval += compare_to_cdstream(bkpinfo);
626 } else {
627 retval += compare_to_CD(bkpinfo);
628 }
629 if (retval) {
630 mvaddstr_and_log_it(g_currentY++,
631 0,
632 "Warning - differences found during the compare phase");
633 }
634
635 retval += unmount_all_devices(mountlist);
636
637 if (count_lines_in_file("/tmp/changed.txt") > 0) {
638 mvaddstr_and_log_it(g_currentY++, 0,
639 "Differences found while files were being compared.");
640 streamline_changes_file("/tmp/changed.files", "/tmp/changed.txt");
641 if (count_lines_in_file("/tmp/changed.files") <= 0) {
642 mvaddstr_and_log_it(g_currentY++, 0,
643 "...but they were logfiles and temporary files. Your archives are fine.");
644 log_to_screen
645 ("The differences were logfiles and temporary files. Your archives are fine.");
646 } else {
647 q = count_lines_in_file("/tmp/changed.files");
648 sprintf(tmp, "%ld significant difference%s found.", q,
649 (q != 1) ? "s" : "");
650 mvaddstr_and_log_it(g_currentY++, 0, tmp);
651 log_to_screen(tmp);
652
653 strcpy(tmp,
654 "Type 'less /tmp/changed.files' for a list of non-matching files");
655 mvaddstr_and_log_it(g_currentY++, 0, tmp);
656 log_to_screen(tmp);
657
658 log_msg(2, "calling popup_changelist_from_file()");
659 popup_changelist_from_file("/tmp/changed.files");
660 log_msg(2, "Returning from popup_changelist_from_file()");
661 }
662 } else {
663 log_to_screen
664 ("No significant differences were found. Your backup is perfect.");
665 }
666 kill_petris();
667 paranoid_free(tmp);
668 return (retval);
669}
670
671/**************************************************************************
672 *END_COMPARE_MODE *
673 **************************************************************************/
674
675/**
676 * Compare all data on a cdstream-based backup.
677 * @param bkpinfo The backup information structure. Fields used:
678 * - @c bkpinfo->disaster_recovery
679 * - @c bkpinfo->media_device
680 * - @c bkpinfo->restore_path
681 * @return 0 for success, nonzero for failure.
682 */
683int compare_to_cdstream(struct s_bkpinfo *bkpinfo)
684{
685 int res;
686
687 /** needs malloc **/
688 char *dir, *command;
689
690 assert(bkpinfo != NULL);
691 malloc_string(dir);
692 malloc_string(command);
693 getcwd(dir, MAX_STR_LEN);
694 chdir(bkpinfo->restore_path);
695
696 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
697 bkpinfo->restore_path);
698 run_program_and_log_output(command, FALSE);
699 mvaddstr_and_log_it(g_currentY,
700 0, "Verifying archives against filesystem");
701
702 if (bkpinfo->disaster_recovery
703 && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
704 strcpy(bkpinfo->media_device,
705 last_line_of_file("/tmp/CDROM-LIVES-HERE"));
706 } else {
707 find_cdrom_device(bkpinfo->media_device, FALSE);
708 }
709 res = verify_tape_backups(bkpinfo);
710 chdir(dir);
711 if (length_of_file("/tmp/changed.txt") > 2
712 && length_of_file("/tmp/changed.files") > 2) {
713 log_msg(0,
714 "Type 'less /tmp/changed.files' to see which files don't match the archives");
715 log_msg(2, "Calling popup_changelist_from_file()");
716 popup_changelist_from_file("/tmp/changed.files");
717 log_msg(2, "Returned from popup_changelist_from_file()");
718 }
719
720 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
721 paranoid_free(dir);
722 paranoid_free(command);
723 return (res);
724}
725
726/**************************************************************************
727 *END_COMPARE_CD_STREAM *
728 **************************************************************************/
729
730
731/**
732 * Compare all data on a tape-based backup.
733 * @param bkpinfo The backup information structure. Field used: @c bkpinfo->restore_path.
734 * @return 0 for success, nonzero for failure.
735 */
736/**************************************************************************
737 * F@COMPARE_TO_TAPE() *
738 * compare_to_tape() - gots me?? *
739 * *
740 * returns: int *
741 **************************************************************************/
742int compare_to_tape(struct s_bkpinfo *bkpinfo)
743{
744 int res;
745 char *dir, *command;
746
747 assert(bkpinfo != NULL);
748 malloc_string(dir);
749 malloc_string(command);
750
751 getcwd(dir, MAX_STR_LEN);
752 chdir(bkpinfo->restore_path);
753 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
754 bkpinfo->restore_path);
755 run_program_and_log_output(command, FALSE);
756 mvaddstr_and_log_it(g_currentY,
757 0, "Verifying archives against filesystem");
758 res = verify_tape_backups(bkpinfo);
759 chdir(dir);
760 if (res) {
761 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
762 } else {
763 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
764 }
765 paranoid_free(dir);
766 paranoid_free(command);
767 return (res);
768}
769
770/**************************************************************************
771 *END_COMPARE_TO_TAPE *
772 **************************************************************************/
773
774/* @} - end compareGroup */
Note: See TracBrowser for help on using the repository browser.