source: MondoRescue/branches/3.3/mondo/src/mondorestore/mondo-rstr-compare.c@ 3875

Last change on this file since 3875 was 3875, checked in by Bruno Cornec, 4 months ago

find_dvd|cdrom_device merged into a rewritten find_optical_device - adds find_usb_device and find_device - mount_CDROM_here moved to mount_media (ongoing)

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