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

Last change on this file since 2324 was 2324, checked in by Bruno Cornec, 15 years ago

r3335@localhost: bruno | 2009-08-08 23:04:12 +0200

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