source: MondoRescue/branches/3.2/mondo/src/mondorestore/mondo-rstr-compare.c@ 3194

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