예제 #1
0
def scan_vg_entries(bu_vg):
    """
    Probe LVM VG bu_vg for filesystems, disk images and others
    return a list of LVMBackupGroups
    """
    def add_bu_entry(bu_group, path, fst, is_mapping=False):
        assert isinstance(bu_group, BackupGroup)
        tmp = BackupEntry(path, fst, needs_mapping=is_mapping)
        bu_group.add_entry(tmp)
    
    bu_group_list = set()
    
    for entry in os.listdir(os.path.join("/dev", bu_vg)):
        entry = os.path.join("/dev", bu_vg, entry)
        tmp_bu_group = LVMBackupGroup(os.path.basename(entry), bu_vg)
        fst = get_fstype(entry)
        if fst is not None:
            add_bu_entry(tmp_bu_group, entry, fst)
        
        else:
            pt_entries = partition.get_pt_entries(entry)
            pt_mappings = partition.create_mappings(entry, pt_entries)
            
            for subentry in pt_mappings:
                prefix, name = subentry
                fst = get_fstype("/dev/mapper/" + prefix + name)
                if fst is not None:
                    add_bu_entry(tmp_bu_group, name, fst, is_mapping=True)
            
            partition.remove_mappings(pt_mappings)
            
        bu_group_list.add(tmp_bu_group)
        
    return bu_group_list
예제 #2
0
    def create_backup_entries(self, fst_list):
        """
        Scan the BackupGroup.parent_dev for sub-entries and add those to the bu_list
        """
        pt_entries = partition.get_pt_entries(self.parent_dev)
        if pt_entries:
            self._pt_entries = pt_entries
            
            for index, entry in enumerate(pt_entries, start=0):
                fst = fs.get_fstype(self.parent_dev, fst_list,
                                    seek = (entry.start * 512))
                if not fst:
                    fst = defaultFST

                if fst.name.lower().strip() == "ufs_bsd"  and entry.name.endswith("p1"):
                    print "Skipping dummy BSD Partition", entry.name
                    pt_entries.pop(index)
                    continue
                
                #Create BackupEntry in persistent storage:
                e_persist = self.Persist_cur.add_entry(mapping_start=entry.start,mapping_end=entry.end)
                
                tmp = BackupEntry(entry.name, fst, self.destpath, needs_mapping = True,
                                  compressor=self._group_compression,
                                  compress_threads = self._compress_threads,
                                  compress_level = self._compress_level,
                                  persist_obj = e_persist)
                self.add_entry(tmp)

        else:
            self._pt_entries = []
            fst = fs.get_fstype(self.parent_dev,fst_list)
            if fst:
                e_persist = self.Persist_cur.add_entry()
                tmp = BackupEntry(self.name, fst, self.destpath, needs_mapping = False,
                                  compressor = self._group_compression,
                                  compress_threads = self._compress_threads,
                                  compress_level = self._compress_level, persist_obj = e_persist)
                self.add_entry(tmp)

        
        #Having added all the entries, check if any of them actually need backup,
        #if so, this function handles all the entries to see whether it needs
        #processing, and if none of them need processing the entire BackupGroup
        #is skipped, no snapshots are created, no mappings are made etc.
        self._determine_actions()