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

Last change on this file since 3193 was 3193, checked in by Bruno Cornec, 11 years ago
  • Finish with backports from 3.1 for now. Still some work to do, but we will now make that version compile and work again and serve as a base

so the gettext patch can be added

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