source: MondoRescue/branches/3.2/mondo/src/mondorestore/mondo-rstr-compare.c@ 3300

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