source: MondoRescue/branches/3.3/mondo/src/mondorestore/mondo-rstr-compare.c@ 3868

Last change on this file since 3868 was 3866, checked in by Bruno Cornec, 5 months ago

Change find_my_editor and find_home_of_exe to return dynamically assigned stringsi - adapt whine_if_not_found

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