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

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

log_msg => mr_msg for main files

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