source: MondoRescue/branches/2.2.5/mondo/src/mondorestore/mondo-rstr-compare.c@ 1630

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

Fix #195 (patch from Scott Cummings)

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