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

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

r3334@localhost: bruno | 2009-08-08 12:17:37 +0200

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