def restore_media_items(config, domain, vectors): tape = ltoUtil.get_tape_device(config) restore_dir = ltoUtil.get_restore_dir(config) bs = int(ltoUtil.get_blocksize(config)) blocking_factor = bs/512 setup_done = False prev_tape_id = "" for v in vectors: tape_id = v[0] offset = v[1] filesize = v[2] record_offset = v[3] filename = v[4] md5 = v[5] blocks = int(filesize/bs)+2 trim = (record_offset*512)%bs if not prev_tape_id == tape_id: raw_input('Insert tape: '+tape_id+' [Press Enter to continue]') if not setup_done: ltoWriteUtil.setup_tape_drive(config) setup_done = True print '\nSeeking to tape block: '+str(offset) p = subprocess.Popen('mt -f '+tape+' seek '+str(offset), shell=True) sts = os.waitpid(p.pid, 0) print 'Restoring file: '+filename p = subprocess.Popen('dd if='+tape+' bs='+str(bs)+' count='+str(blocks)+' | dd bs='+str(trim)+' skip=1 | tar -x -C '+restore_dir+' '+filename+' --occurrence', shell=True, stderr=subprocess.PIPE) sts = os.waitpid(p.pid, 0) #md5 check restored files if md5 == ltoUtil.get_md5_hash(restore_dir+'/'+filename): print 'Verified MD5: '+filename else: print 'MD5 verification failed for '+filename #Rename files to include event metadata extra_metadata_str = get_session_full_name(config, session_id) filepath = restore_dir+'/'+filename ltoUtil.move(filepath, filepath[:-4]+'_'+extra_metadata_str+'.'+ltoUtil.get_file_extn(filepath)) prev_tape_id = tape_id print '\nAll files successfully restored to '+ltoUtil.get_restore_dir(config)
def main(): parser = optparse.OptionParser(version="%prog 1.0") parser.add_option("-v", "--verify", dest="verify", action="store-true", help="Verify tape after writing") (options, args) = parser.parse_args() verify = options.verify ltoWriteUtil.check_write_args(args) tape_id = args[0] config = ConfigParser.ConfigParser() ltoUtil.load_config(config) ltoUtil.config_checks(config) ltoUtil.path_check(ltoUtil.get_tape_pending_dir(config)+'/'+tape_id) ltoWriteUtil.verify_virtual_tape(config, tape_id) ltoWriteUtil.setup_tape_drive(config) ltoWriteUtil.write_tape(config, tape_id) ltoUtil.move_virtual_tape_dir(config, tape_id, 'pending', 'written')
def main(): parser = optparse.OptionParser(version="%prog 1.0") (options, args) = parser.parse_args() ltoWriteUtil.check_write_args(args) tape_id = args[0] config = ConfigParser.ConfigParser() ltoUtil.load_config(config) ltoUtil.config_checks(config) ltoUtil.path_check(ltoUtil.get_tape_written_dir(config)+'/'+tape_id) ltoUtil.file_check(ltoUtil.get_tape_written_dir(config)+'/'+tape_id+'/'+tape_id+'.xml') ltoVerifyUtil.diskspace_check(config, tape_id) ltoUtil.delete_dir_content(ltoUtil.get_tape_verify_dir(config)) ltoWriteUtil.setup_tape_drive(config) ltoVerifyUtil.verify_tape(config, tape_id) ltoUtil.move_virtual_tape_dir(config, tape_id, 'written', 'verified') ltoUtil.delete_dir_content(ltoUtil.get_tape_verify_dir(config))