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

Last change on this file since 3613 was 3613, checked in by Bruno Cornec, 7 years ago

Add function mr_getcwd and use it to allow use o dynamically allocated memory
instead of getcwd

  • Property svn:keywords set to Id
File size: 21.2 KB
RevLine 
[1]1/***************************************************************************
[128]2 cvsid : $Id: mondo-rstr-compare.c 3613 2016-11-18 16:31:42Z 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 3613 2016-11-18 16:31:42Z 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) {
261 mr_asprintf(tmp, "%s", compressor_exe);
[128]262 if (!find_home_of_exe(tmp)) {
[3193]263 mr_free(tmp);
264 mr_free(compressor_exe);
265 mr_free(archiver_exe);
[128]266 fatal_error("(compare_a_tarball) Compression program missing");
267 }
[3193]268 mr_free(tmp);
269
270 if (use_star) {
[128]271 if (!strcmp(compressor_exe, "bzip2")) {
[2211]272 mr_strcat(archiver_exe, " -bz");
[128]273 } else {
[3193]274 mr_free(compressor_exe);
275 mr_free(archiver_exe);
276 fatal_error("(compare_a_tarball) Please use only bzip2 with star");
[128]277 }
[3193]278 } else {
279 // afio
280 mr_asprintf(tmp, "%s", compressor_exe);
281 mr_free(compressor_exe);
282 mr_asprintf(compressor_exe, "-P %s -Z", tmp);
283 mr_free(tmp);
[128]284 }
285 }
[1]286
287#ifdef __FreeBSD__
288#define BUFSIZE 512L
289#else
290#define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE
291#endif
[3193]292 mr_asprintf(logfile, "/tmp/afio.log.%d", current_tarball_number);
293
294 if (use_star) {
295 // doesn't use compressor_exe
296 mr_asprintf(command, "%s -sparse -diff H=exustar file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile);
[128]297 } else {
[3193]298 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]299 }
[3193]300 mr_free(compressor_exe);
301 mr_free(archiver_exe);
[2211]302
[1]303#undef BUFSIZE
304
[128]305 res = system(command);
306 retval += res;
307 if (res) {
308 log_OS_error(command);
[3193]309 log_msg(2, "Warning - afio returned error = %d", res);
[128]310 }
[3193]311 mr_free(command);
312
[128]313 if (length_of_file(logfile) > 5) {
[3193]314 mr_asprintf(command, "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", logfile);
[3060]315 paranoid_system(command);
[3193]316 mr_free(command);
317
[128]318 archiver_errors = count_lines_in_file(logfile);
319 } else {
320 archiver_errors = 0;
321 }
322 if (archiver_errors) {
[3193]323 log_msg(1, "%ld difference%c in fileset #%d ", archiver_errors, (archiver_errors != 1) ? 's' : ' ', current_tarball_number);
[128]324 }
325 unlink(logfile);
[3193]326 mr_free(logfile);
327
[128]328 return (retval);
[1]329}
[128]330
[1]331/**************************************************************************
332 *END_COMPARE_A_TARBALL *
333 **************************************************************************/
334
335
336/**
337 * Compare all afioballs in this backup.
338 * @param bkpinfo The backup media structure. Passed to other functions.
339 * @return 0 for success, nonzero for failure.
340 */
[1645]341int compare_all_tarballs()
[1]342{
[128]343 int retval = 0;
344 int current_tarball_number = 0;
[1]345
346 /** needs malloc **********/
347
[3193]348 char *tarball_fname = NULL;
349 char *progress_str = NULL;
350 char *tmp = NULL;
[2242]351 char *mds = NULL;
[128]352 long max_val;
[1]353
[128]354 malloc_string(tmp);
355 assert(bkpinfo != NULL);
[541]356 mvaddstr_and_log_it(g_currentY, 0, "Comparing archives");
[128]357 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
[3193]358 max_val = atol(tmp);
359 paranoid_free(tmp);
[128]360
[2242]361 mds = media_descriptor_string(bkpinfo->backup_media_type);
[3193]362 mr_asprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
[128]363
[541]364 open_progress_form("Comparing files",
365 "Comparing tarballs against filesystem.",
366 "Please wait. This may take some time.",
[128]367 progress_str, max_val);
368
369 log_to_screen(progress_str);
370
371 for (;;) {
[1645]372 insist_on_this_cd_number(g_current_media_number);
[128]373 update_progress_form(progress_str);
[3193]374 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.bz2", 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.lzo", current_tarball_number);
[128]379 }
380 if (!does_file_exist(tarball_fname)) {
[3193]381 mr_free(tarball_fname);
382 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzma", current_tarball_number);
[1630]383 }
384 if (!does_file_exist(tarball_fname)) {
[3193]385 mr_free(tarball_fname);
386 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.gz", 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.afio.", 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.bz2", current_tarball_number);
[128]395 }
396 if (!does_file_exist(tarball_fname)) {
[3193]397 mr_free(tarball_fname);
398 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%d.star.", current_tarball_number);
399 }
400 if (!does_file_exist(tarball_fname)) {
[128]401 if (!does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST") ||
402 system("find " MNT_CDROM
403 "/archives/slice* > /dev/null 2> /dev/null")
404 == 0) {
405 log_msg(2, "OK, I think I'm done with tarballs...");
[3193]406 mr_free(tarball_fname);
[128]407 break;
408 }
409 log_msg(2, "OK, I think it's time for another CD...");
410 g_current_media_number++;
[3193]411
412 mr_free(progress_str);
413 mr_asprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
[128]414 log_to_screen(progress_str);
415 } else {
[3060]416 retval += compare_a_tarball(tarball_fname, current_tarball_number);
[128]417
418 g_current_progress++;
419 current_tarball_number++;
420 }
[3193]421 mr_free(tarball_fname);
[1]422 }
[3193]423 mr_free(progress_str);
[2242]424 mr_free(mds);
425
[128]426 close_progress_form();
427 if (retval) {
[541]428 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
[128]429 } else {
[541]430 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
[1]431 }
[128]432 return (retval);
[1]433}
[128]434
[1]435/**************************************************************************
436 *END_COMPARE_ALL_TARBALLS *
437 **************************************************************************/
438
439/* @} - end LLcompareGroup */
440
441
442/**
443 * @addtogroup compareGroup
444 * @{
445 */
446/**
447 * Compare all data on a CD-R/CD-RW/DVD/ISO/NFS-based backup.
448 * @param bkpinfo The backup information structure. Passed to other functions.
449 * @return 0 for success, nonzero for failure.
450 */
[1645]451int compare_to_CD()
[1]452{
453 /** needs malloc *********/
[3193]454 char *tmp = NULL;
[3613]455 char *old_pwd = NULL;
[3193]456 char *command = NULL;
[128]457 int resA = 0;
458 int resB = 0;
459 long noof_changed_files;
[1]460
[128]461 malloc_string(tmp);
462 assert(bkpinfo != NULL);
463
[3613]464 old_pwd = mr_getcwd();
[3060]465 if (chdir(bkpinfo->restore_path)) {
466 //FIXME
467 }
[1645]468 insist_on_this_cd_number(g_current_media_number);
[1747]469 unlink(MONDO_CACHE"/changed.txt");
[128]470
[1645]471 resA = compare_all_tarballs();
472 resB = compare_all_biggiefiles();
[3613]473 if (chdir(old_pwd)) {
[3060]474 // FIXME
475 }
[3613]476 mr_free(old_pwd);
477
[1747]478 noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt");
[128]479 if (noof_changed_files) {
[3193]480 log_to_screen("%ld files do not match the backup ", noof_changed_files);
481
482 mr_asprintf(command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE);
[128]483 paranoid_system(command);
[3193]484 mr_free(command);
[128]485 } else {
[3193]486 mr_asprintf(tmp, "All files match the backup ");
[128]487 mvaddstr_and_log_it(g_currentY++, 0, tmp);
488 log_to_screen(tmp);
[3193]489 mr_free(tmp);
[128]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;
[3193]517 char *tmp = NULL;
[3613]518 char *old_pwd = NULL;
[1]519
520 /**************************************************************************
521 * also deletes tmp/filelist.full & tmp/biggielist.txt _and_ tries to *
522 * restore them from start of tape, if available *
523 **************************************************************************/
[128]524 assert(bkpinfo != NULL);
525 assert(mountlist != NULL);
526 assert(raidlist != NULL);
[1]527
[1645]528 while (get_cfg_file_from_archive()) {
[128]529 if (!ask_me_yes_or_no
[541]530 ("Failed to find config file/archives. Choose another source?"))
[128]531 {
532 fatal_error("Unable to find config file/archives. Aborting.");
533 }
[1645]534 interactively_obtain_media_parameters_from_user(FALSE);
[128]535 }
[1]536
[1645]537 read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
[1664]538
539 /* edit_mountlist if wanted */
[2230]540 log_it("About to edit mountlist");
[1664]541 if (g_text_mode) {
542 save_mountlist_to_disk(mountlist, g_mountlist_fname);
543 sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);
544 res = system(tmp);
545 load_mountlist(mountlist, g_mountlist_fname);
546 } else {
547 res = edit_mountlist(g_mountlist_fname, mountlist, raidlist);
548 }
[2230]549 log_it("Finished editing mountlist");
[1664]550 if (res) {
551 paranoid_MR_finish(1);
552 }
553 save_mountlist_to_disk(mountlist, g_mountlist_fname);
554 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
555
[128]556 g_current_media_number = 1;
[541]557 mvaddstr_and_log_it(1, 30, "Comparing Automatically");
[2230]558 log_it("Pre-MAD");
[128]559 retval = mount_all_devices(mountlist, FALSE);
[2230]560 log_it("Post-MAD");
[128]561 if (retval) {
562 unmount_all_devices(mountlist);
563 return (retval);
564 }
565 if (bkpinfo->backup_media_type == tape
566 || bkpinfo->backup_media_type == udev) {
[1645]567 retval += compare_to_tape();
[128]568 } else if (bkpinfo->backup_media_type == cdstream) {
[1645]569 retval += compare_to_cdstream();
[128]570 } else {
[1645]571 retval += compare_to_CD();
[128]572 }
573 if (retval) {
574 mvaddstr_and_log_it(g_currentY++,
575 0,
[541]576 "Warning - differences found during the compare phase");
[128]577 }
[1]578
[1747]579 if (count_lines_in_file(MONDO_CACHE"/changed.txt") > 0) {
[128]580 mvaddstr_and_log_it(g_currentY++, 0,
[541]581 "Differences found while files were being compared.");
[1747]582 streamline_changes_file(MONDO_CACHE"/changed.files", MONDO_CACHE"/changed.txt");
583 if (count_lines_in_file(MONDO_CACHE"/changed.files") <= 0) {
[128]584 mvaddstr_and_log_it(g_currentY++, 0,
[541]585 "...but they were logfiles and temporary files. Your archives are fine.");
[128]586 log_to_screen
[541]587 ("The differences were logfiles and temporary files. Your archives are fine.");
[128]588 } else {
[1747]589 q = count_lines_in_file(MONDO_CACHE"/changed.files");
[3193]590 mr_asprintf(tmp, "%ld significant difference%s found.", q, (q != 1) ? "s" : "");
[128]591 mvaddstr_and_log_it(g_currentY++, 0, tmp);
592 log_to_screen(tmp);
[3193]593 mr_free(tmp);
[1]594
[3193]595 mr_asprintf(tmp, "Type 'less /tmp/changed.files' for a list of non-matching files");
[128]596 mvaddstr_and_log_it(g_currentY++, 0, tmp);
597 log_to_screen(tmp);
[3193]598 mr_free(tmp);
[1]599
[128]600 log_msg(2, "calling popup_changelist_from_file()");
[3613]601 old_pwd = mr_getcwd();
[3060]602 if (chdir(bkpinfo->restore_path)) {
603 // FIXME
604 }
[1747]605 popup_changelist_from_file(MONDO_CACHE"/changed.files");
[3613]606 if (chdir(old_pwd)) {
[3060]607 // FIXME
608 }
[3613]609 mr_free(old_pwd);
[128]610 log_msg(2, "Returning from popup_changelist_from_file()");
611 }
612 } else {
613 log_to_screen
[541]614 ("No significant differences were found. Your backup is perfect.");
[1]615 }
[1585]616 retval += unmount_all_devices(mountlist);
617
[128]618 kill_petris();
619 return (retval);
[1]620}
621
622/**************************************************************************
623 *END_COMPARE_MODE *
624 **************************************************************************/
625
626/**
627 * Compare all data on a cdstream-based backup.
628 * @param bkpinfo The backup information structure. Fields used:
629 * - @c bkpinfo->disaster_recovery
630 * - @c bkpinfo->media_device
631 * - @c bkpinfo->restore_path
632 * @return 0 for success, nonzero for failure.
633 */
[1645]634int compare_to_cdstream()
[1]635{
[128]636 int res;
[1]637
638 /** needs malloc **/
[3193]639 char *dir;
640 char *command = NULL;
[1]641
[128]642 assert(bkpinfo != NULL);
643 malloc_string(dir);
[3060]644 if (getcwd(dir, MAX_STR_LEN)) {
645 // FIXME
646 }
647 if (chdir(bkpinfo->restore_path)) {
648 // FIXME
649 }
[1]650
[3193]651 mr_asprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path);
[128]652 run_program_and_log_output(command, FALSE);
[3193]653 mr_free(command);
654 mvaddstr_and_log_it(g_currentY, 0, "Verifying archives against filesystem");
[1]655
[128]656 if (bkpinfo->disaster_recovery
657 && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
658 strcpy(bkpinfo->media_device,
659 last_line_of_file("/tmp/CDROM-LIVES-HERE"));
660 } else {
661 find_cdrom_device(bkpinfo->media_device, FALSE);
662 }
[1645]663 res = verify_tape_backups();
[3060]664 if (chdir(dir)) {
665 // FIXME
666 }
[1747]667 if (length_of_file(MONDO_CACHE"/changed.txt") > 2
668 && length_of_file(MONDO_CACHE"/changed.files") > 2) {
[128]669 log_msg(0,
[1747]670 "Type 'less "MONDO_CACHE"/changed.files' to see which files don't match the archives");
[128]671 log_msg(2, "Calling popup_changelist_from_file()");
[1747]672 popup_changelist_from_file(MONDO_CACHE"/changed.files");
[128]673 log_msg(2, "Returned from popup_changelist_from_file()");
674 }
675
[541]676 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
[128]677 paranoid_free(dir);
678 return (res);
[1]679}
[128]680
[1]681/**************************************************************************
682 *END_COMPARE_CD_STREAM *
683 **************************************************************************/
684
685
686/**
687 * Compare all data on a tape-based backup.
688 * @param bkpinfo The backup information structure. Field used: @c bkpinfo->restore_path.
689 * @return 0 for success, nonzero for failure.
690 */
691/**************************************************************************
692 * F@COMPARE_TO_TAPE() *
693 * compare_to_tape() - gots me?? *
694 * *
695 * returns: int *
696 **************************************************************************/
[1645]697int compare_to_tape()
[1]698{
[128]699 int res;
[3193]700 char *dir;
701 char *command = NULL;
[1]702
[128]703 assert(bkpinfo != NULL);
704 malloc_string(dir);
705
[3060]706 if (getcwd(dir, MAX_STR_LEN)) {
707 // FIXME
708 }
709 if (chdir(bkpinfo->restore_path)) {
710 // FIXME
711 }
[3193]712 mr_asprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path);
[128]713 run_program_and_log_output(command, FALSE);
[3193]714 mr_free(command);
715
716 mvaddstr_and_log_it(g_currentY, 0, "Verifying archives against filesystem");
[1645]717 res = verify_tape_backups();
[3060]718 if (chdir(dir)) {
719 // FIXME
720 }
[128]721 if (res) {
[541]722 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
[128]723 } else {
[541]724 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
[128]725 }
726 paranoid_free(dir);
727 return (res);
[1]728}
729
730/**************************************************************************
731 *END_COMPARE_TO_TAPE *
732 **************************************************************************/
733
734/* @} - end compareGroup */
Note: See TracBrowser for help on using the repository browser.