source: MondoRescue/branches/stable/mondo/mondo/mondorestore/mondo-rstr-compare.c@ 541

Last change on this file since 541 was 541, checked in by bcornec, 18 years ago

Stable is reverted to r436 (2.0.7) to put it in line with 2.0.8 and start from there over

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