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

Last change on this file since 1670 was 1670, checked in by Bruno Cornec, 17 years ago
  • Try to fix the issue with large exclude list (> 1000 chars) Some variables created after exclude_path (indirectly) were not sized big enough to handle them.
  • Remove useless .keep file
  • remove temporary.iso name remaining and suppress a warning in log trying to remove it in the tmpdir
  • missing extern bkpinfo in newt-specific.c
  • Attempt to fix #191 (allow edition of mountlist in compare mode)

(merge -r1662:1669 $SVN_M/branches/2.2.5)

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