source: MondoRescue/trunk/mondo/mondo/mondorestore/mondo-rstr-compare.c@ 30

Last change on this file since 30 was 30, checked in by bcornec, 19 years ago

Id property added on files to allow for better conf. management

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