Backup an anchore installation to a tarfile.
435281
def backup(outputdir):
    

    ecode = 0
    try:
        anchore_print('Backing up anchore system to directory '+str(outputdir)+' ...')
        backupfile = config.backup(outputdir)
        anchore_print({"anchore_backup_tarball":str(backupfile)}, do_formatting=True)
    except Exception as err:
        anchore_print_err('operation failed')
        ecode = 1

    sys.exit(ecode)
812591
def mount(self,
              fstype=None,
              options=None,
              auth_no_user_interaction=None):
        """"""
        return self._M.Filesystem.Mount(
            '(a{sv})',
            filter_opt({
                'fstype': ('s', fstype),
                'options': ('s', ','.join(options or [])),
                'auth.no_user_interaction': ('b', auth_no_user_interaction),
            })
        )
926034
def backup(self):
        """"""
        count = 0
        name = "{}.bkp".format(self.filename)
        backup = os.path.join(self.cwd, name)
        while os.path.exists(backup):
            count += 1
            name = "{}.bkp{}".format(self.filename, count)
            backup = os.path.join(self.cwd, name)
        self.hey("Moving existing {} to {}".format(self.filename, name))
        os.rename(os.path.join(self.cwd, self.filename), backup)
1251643
def saveHdlFiles(self, srcDir):
        
        path = os.path.join(srcDir, self.name)
        try:
            os.makedirs(path)
        except OSError:
            # wipe if exists
            shutil.rmtree(path)
            os.makedirs(path)

        files = self.hdlFiles
        self.hdlFiles = self.toHdlConversion(self.top, self.name, path)
        for srcF in files:
            dst = os.path.join(path,
                               os.path.relpath(srcF, srcDir).replace('../', '')
                               )
            os.makedirs(os.path.dirname(dst), exist_ok=True)
            shutil.copy(srcF, dst)
            self.hdlFiles.append(dst)
262277
def get_asset_tarball(asset_name, src_dir, dest_project, dest_folder, json_out):
    
    if os.path.isdir(os.path.join(src_dir, "resources")):
        temp_dir = tempfile.mkdtemp()
        try:
            resource_file = os.path.join(temp_dir, asset_name + "_resources.tar.gz")
            cmd = ["tar", "-czf", resource_file, "-C", os.path.join(src_dir, "resources"), "."]
            subprocess.check_call(cmd)
            file_id = dx_upload(resource_file, dest_project, dest_folder, json_out)
            return file_id
        finally:
            shutil.rmtree(temp_dir)
992520
def extract_tar (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    try:
        with tarfile.open(archive) as tfile:
            tfile.extractall(path=outdir)
    except Exception as err:
        msg = "error extracting %s: %s" % (archive, err)
        raise util.PatoolError(msg)
    return None
355194
def backup(path, name=None):
    """"""
    from PyHardLinkBackup.phlb.phlb_main import backup

    backup(path, name)
197367
def setup(self):
        
        if self.backup:
            shutil.copy(self.input_file, "{}.orig".format(self.input_file))
935017
def packfile(filename, srcdir):
    """"""
    if filename.endswith(".mar"):
        return packmar(filename, srcdir)
    elif filename.endswith(".exe"):
        return packexe(filename, srcdir)
    elif filename.endswith(".tar"):
        return tar_dir(filename, srcdir)
    else:
        raise ValueError("Unknown file type: %s" % filename)
285911
def _generate_tar(dir_path):
    """"""
    try:
        with tarfile.open(dir_path + '.tar', 'w') as tar:
            tar.add(dir_path)
    except tarfile.TarError as e:
        stderr("Error: tar archive creation failed [" + str(e) + "]", exit=1)
569921
def setup_container(builddir, _container):
    """"""
    build_dir = local.path(builddir)
    in_dir = build_dir / "container-in"
    container_path = local.path(_container)
    with local.cwd(builddir):
        container_bin = container_path.basename
        container_in = in_dir / container_bin
        download.Copy(_container, container_in)
        uchrt = uchroot.no_args()

        with local.cwd("container-in"):
            uchrt = uchrt["-E", "-A", "-u", "0", "-g", "0", "-C", "-r", "/",
                          "-w",
                          os.path.abspath("."), "--"]

        # Check, if we need erlent support for this archive.
        has_erlent = bash[
            "-c", "tar --list -f './{0}' | grep --silent '.erlent'".format(
                container_in)]
        has_erlent = (has_erlent & TF)

        # Unpack input container to: container-in
        if not has_erlent:
            cmd = local["/bin/tar"]["xf"]
            cmd = uchrt[cmd[container_bin]]
        else:
            cmd = tar["xf"]
            cmd = cmd[container_in]

        with local.cwd("container-in"):
            cmd("--exclude=dev/*")
        rm(container_in)
    return in_dir
137850
def install(name, link, path, priority):
    '''
    
    '''
    cmd = [_get_cmd(), '--install', link, name, path, six.text_type(priority)]
    out = __salt__['cmd.run_all'](cmd, python_shell=False)
    if out['retcode'] > 0 and out['stderr'] != '':
        return out['stderr']
    return out['stdout']
242711
def extract_archive(archive_path, destination_path):
    """"""
    tar = tarfile.open(archive_path)
    tar.errorlevel = 1
    tar.extractall(destination_path)
1242098
def _backup_file(path):
    
    backup_base = '/var/local/woven-backup'
    backup_path = ''.join([backup_base,path])
    if not exists(backup_path):
        directory = ''.join([backup_base,os.path.split(path)[0]])
        sudo('mkdir -p %s'% directory)
        sudo('cp %s %s'% (path,backup_path))
1211672
def mount(dev, mountpoint, flags='', log=None):
    ''''''
    ensureDirectory(mountpoint)
    systemCall('mount %s %s %s' % (flags, dev, mountpoint),
               log=log)
655805
def _dir_tar_out(self):
        """"""
        return os.path.join(self.proj.tar_direc_out, self.proj.name,
                            self.model.name, self.run.name)
1128024
def makeBackupFile(self, dstPath, fileName):
        

        with open(os.devnull) as devnull:
            SP.call(['mongodump', '--db', self.dbName, '--out', dstPath],
                    stdout=devnull,
                    stderr=devnull)
            SP.call(['zip',
                     '-r',
                     os.path.join(dstPath, fileName),
                     os.path.join(dstPath, self.dbName)],
                    stdout=devnull,
                    stderr=devnull)

        SP.call(['rm', '-rf', os.path.join(dstPath, self.dbName)])