Changeset 914 in MondoRescue for trunk/mondo/src/mondorestore


Ignore:
Timestamp:
Nov 2, 2006, 2:00:32 AM (17 years ago)
Author:
Bruno Cornec
Message:

merge -r902:913 $SVN_M/branches/stable

Location:
trunk/mondo/src/mondorestore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/src/mondorestore/mondo-restore.c

    r900 r914  
    20462046        mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    20472047        mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    2048         tmp = find_home_of_exe("setfacl");
    2049         if (length_of_file(acl_fname) > 0 && tmp) {
     2048        if (length_of_file(acl_fname) > 0) {
    20502049            set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname);
    20512050        }
    2052         mr_free(tmp);
    2053 
    2054         tmp = find_home_of_exe("setfattr");
    2055         if (length_of_file(xattr_fname) > 0 && tmp) {
     2051        if (length_of_file(xattr_fname) > 0) {
    20562052            set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname);
    20572053        }
    2058         mr_free(tmp);
    20592054        mr_free(acl_fname);
    20602055        mr_free(xattr_fname);
     
    26242619
    26252620
     2621/**
     2622 * @brief Haha. You wish! (This function is not implemented :-)
     2623 */
     2624int
     2625restore_live_from_monitas_server(struct s_bkpinfo *bkpinfo,
     2626                                 char *monitas_device,
     2627                                 char *restore_this_directory,
     2628                                 char *restore_here)
     2629     /* NB: bkpinfo hasn't been populated yet, except for ->tmp which is "/tmp" */
     2630{
     2631    FILE *fout;
     2632    int retval = 0;
     2633    int i;
     2634    int j;
     2635    struct mountlist_itself the_mountlist;
     2636    static struct raidlist_itself the_raidlist;
     2637  /** malloc **/
     2638    char tmp[MAX_STR_LEN + 1];
     2639    char command[MAX_STR_LEN + 1];
     2640    char datablock[256 * 1024];
     2641    char datadisks_fname[MAX_STR_LEN + 1];
     2642    long k;
     2643    long length;
     2644    long long llt;
     2645    struct s_node *filelist = NULL;
     2646    assert(bkpinfo != NULL);
     2647    assert_string_is_neither_NULL_nor_zerolength(monitas_device);
     2648    assert(restore_this_directory != NULL);
     2649    assert(restore_here != NULL);
     2650
     2651    sprintf(tmp, "restore_here = '%s'", restore_here);
     2652
     2653    log_msg(2, tmp);
     2654
     2655    log_msg(2, "restore_live_from_monitas_server() - starting");
     2656    unlink("/tmp/mountlist.txt");
     2657    unlink("/tmp/filelist.full");
     2658    unlink("/tmp/biggielist.txt");
     2659    if (restore_here[0] == '\0') {
     2660        strcpy(bkpinfo->restore_path, MNT_RESTORING);
     2661    } else {
     2662        strcpy(bkpinfo->restore_path, restore_here);
     2663    }
     2664    log_msg(3, "FYI FYI FYI FYI FYI FYI FYI FYI FYI FYI FYI");
     2665    sprintf(tmp, "FYI - data will be restored to %s",
     2666            bkpinfo->restore_path);
     2667    log_msg(3, tmp);
     2668    log_msg(3, "FYI FYI FYI FYI FYI FYI FYI FYI FYI FYI FYI");
     2669    sprintf(datadisks_fname, "/tmp/mondorestore.datadisks.%d",
     2670            (int) (random() % 32768));
     2671    chdir(bkpinfo->tmpdir);
     2672
     2673    sprintf(command, "cat %s", monitas_device);
     2674    g_tape_stream = popen(command, "r");    // for compatibility with openin_tape()
     2675    if (!(fout = fopen(datadisks_fname, "w"))) {
     2676        log_OS_error(datadisks_fname);
     2677        return (1);
     2678    }
     2679    for (i = 0; i < 32; i++) {
     2680        for (j = 0; j < 4; j++) {
     2681            for (length = k = 0; length < 256 * 1024; length += k) {
     2682                k = fread(datablock + length, 1, 256 * 1024 - length,
     2683                          g_tape_stream);
     2684            }
     2685            fwrite(datablock, 1, length, fout);
     2686            g_tape_posK += length;
     2687        }
     2688    }
     2689    paranoid_fclose(fout);
     2690    sprintf(command,
     2691            "tar -zxvf %s tmp/mondo-restore.cfg tmp/mountlist.txt tmp/filelist.full tmp/biggielist.txt",
     2692            datadisks_fname);
     2693    run_program_and_log_output(command, 4);
     2694    read_header_block_from_stream(&llt, tmp, &i);
     2695    read_header_block_from_stream(&llt, tmp, &i);
     2696
     2697    unlink(datadisks_fname);
     2698    read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);
     2699    retval = load_mountlist(&the_mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo   strcpy(bkpinfo->media_device, monitas_device);
     2700
     2701
     2702    load_raidtab_into_raidlist(&the_raidlist, RAIDTAB_FNAME);
     2703    iamhere("FIXME");
     2704    fatal_error("This will fail");
     2705    sprintf(command,
     2706            "grep -E '^%s.*$' %s > %s",
     2707            restore_this_directory, g_filelist_full, g_filelist_full);
     2708    if (system(command)) {
     2709        retval++;
     2710        log_to_screen
     2711            ("Error(s) occurred while processing filelist and wildcard");
     2712    }
     2713    iamhere("FIXME");
     2714    fatal_error("This will fail");
     2715    sprintf(command,
     2716            "grep -E '^%s.*$' %s > %s",
     2717            restore_this_directory, g_biggielist_txt, g_biggielist_txt);
     2718    if (system(command)) {
     2719        log_msg(1,
     2720                "Error(s) occurred while processing biggielist and wildcard");
     2721    }
     2722    sprintf(command, "touch %s", g_biggielist_txt);
     2723    run_program_and_log_output(command, FALSE);
     2724//  filelist = load_filelist(g_filelist_restthese);  // FIXME --- this probably doesn't work because it doesn't include the biggiefiles
     2725    retval += restore_everything(bkpinfo, filelist);
     2726    free_filelist(filelist);
     2727    log_msg(2, "--------End of restore_live_from_monitas_server--------");
     2728    return (retval);
     2729}
     2730
     2731/**************************************************************************
     2732 *END_RESTORE_LIVE_FROM_MONITAS_SERVER                                    *
     2733 **************************************************************************/
     2734
     2735
     2736
     2737
     2738>>>>>>> .fusion-droit.r913
    26262739extern void wait_until_software_raids_are_prepped(char *, int);
    26272740
  • trunk/mondo/src/mondorestore/mondo-rstr-tools-EXT.h

    r688 r914  
    99extern void kill_petris(void);
    1010extern int mount_cdrom(struct s_bkpinfo *bkpinfo);
    11 extern int mount_device(char *, char *, char *, bool);
    1211extern int mount_all_devices(struct mountlist_itself *, bool);
    1312extern void protect_against_braindead_sysadmins(void);
  • trunk/mondo/src/mondorestore/mondo-rstr-tools.c

    r903 r914  
    257257    mr_free(tmp);
    258258
    259     mr_asprintf(&command, "grep -x \"%s\" %s", file, list_fname);
     259    mr_asprintf(&command, "grep -E '^%s$' %s", file, list_fname);
    260260    mr_free(file);
    261261
     
    854854                mr_allocstr(bkpinfo->prefix, STD_PREFIX);
    855855            }
    856             /* We need to override prefix value in PXE mode as it's
    857              * already done in start-nfs */
    858             envtmp1 = getenv("imgname");
    859             if (envtmp1 == NULL) {
    860                 fatal_error("no imgname variable in environment");
    861             }
    862856            if (strstr(call_program_and_get_last_line_of_output
    863857               ("cat /proc/cmdline"), "pxe")) {
    864                     mr_allocstr(bkpinfo->prefix,envtmp1);
     858                /* We need to override prefix value in PXE mode as it's
     859                * already done in start-nfs */
     860                envtmp1 = getenv("imgname");
     861                if (envtmp1 == NULL) {
     862                    fatal_error("no imgname variable in environment");
     863                }
     864                mr_allocstr(bkpinfo->prefix,envtmp1);
    865865            }
    866866
     
    989989            log_msg(2, "nfs_remote_dir is %s", bkpinfo->nfs_remote_dir);
    990990        }
    991         /* We need to override values in PXE mode as it's
    992          * already done in start-nfs */
    993         envtmp1 = getenv("nfsmount");
    994         if (envtmp1 == NULL) {
    995             fatal_error("no nfsmount variable in environment");
    996             }
    997         envtmp2 = getenv("dirimg");
    998         if (envtmp2 == NULL) {
    999             fatal_error("no dirimg variable in environment");
    1000         }
    1001991        if (strstr(call_program_and_get_last_line_of_output
    1002992           ("cat /proc/cmdline"), "pxe")) {
    1003                 mr_allocstr(bkpinfo->nfs_mount,envtmp1);
    1004                 mr_allocstr(bkpinfo->nfs_remote_dir,envtmp2);
     993            /* We need to override values in PXE mode as it's
     994            * already done in start-nfs */
     995            envtmp1 = getenv("nfsmount");
     996            if (envtmp1 == NULL) {
     997                fatal_error("no nfsmount variable in environment");
     998            }
     999            envtmp2 = getenv("dirimg");
     1000            if (envtmp2 == NULL) {
     1001                fatal_error("no dirimg variable in environment");
     1002            }
     1003            mr_allocstr(bkpinfo->nfs_mount,envtmp1);
     1004            mr_allocstr(bkpinfo->nfs_remote_dir,envtmp2);
    10051005        }
    10061006    } else if (bkpinfo->backup_media_type == iso) {
     
    10361036                /* Find out where it's mounted */
    10371037                mr_asprintf(&command,
    1038                         "mount | grep -w %s | tail -n1 | cut -d' ' -f3",
     1038                        "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3",
    10391039                        g_isodir_device);
    10401040                log_it("command = %s", command);
     
    12381238            mr_free(command);
    12391239        }
    1240         mr_asprintf(&command, "grep  -x \"/dev/.*\" %s > %s",
     1240        mr_asprintf(&command, "grep  -E '^/dev/.*$' %s > %s",
    12411241                g_biggielist_txt, g_filelist_imagedevs);
    12421242        paranoid_system(command);
     
    13681368        mr_free(tmp);
    13691369    } else {
    1370         mr_asprintf(&tmp, "ls /dev | grep -xq %ss[1-4].*", device);
     1370        mr_asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*$'", device);
    13711371        if (!system(tmp)) {
    13721372            mr_free(tmp);
  • trunk/mondo/src/mondorestore/mondo-rstr-tools.h

    r688 r914  
    99void kill_petris(void);
    1010int mount_cdrom(struct s_bkpinfo *bkpinfo);
    11 int mount_device(char *, char *, char *, bool);
    1211int mount_all_devices(struct mountlist_itself *, bool);
    1312void protect_against_braindead_sysadmins(void);
Note: See TracChangeset for help on using the changeset viewer.