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

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

log_msg => mr_msg in trunk

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