source: branches/stable/mondo/src/mondorestore/mondo-rstr-compare.c @ 1326

Last change on this file since 1326 was 1326, checked in by bruno, 12 years ago
  • MONDO_LOGFILE is rather a char* exported by each main program (consolidation of those mecanisms in .h files with ps_*)
  • One include has been created for each binary containing only the specific declarations
  • Log files are now consistent: mondoarchive.log for mondoarchive (containing also mindi.log) and mondorestore.log for mondorestore (copied from /tmp (ram) to /var/log (disk) at the end of the restore)
  • Doc updated accordingly
  • LOGFILE in restore process is now passed in the environment and not duplicated a nymore
  • LogIt? is not redifined either
  • LOGFILE should be put in environment by mondoarchive for mindi's usage but that's a step left for later.
  • label-partitions-as-necessary should now work correctly for LABEL and UUID (grep -w removed)
  • Remove useless script compare-me

(All coming from 2.2.2) (remains changes in my-stuff.h coming later on)

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