source: MondoRescue/branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c@ 2405

Last change on this file since 2405 was 2405, checked in by Bruno Cornec, 15 years ago

Removes some malloc_string static allocation

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