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

Last change on this file since 2623 was 2623, checked in by Bruno Cornec, 14 years ago

r3783@localhost: bruno | 2010-04-11 11:57:27 +0200

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