original_docstring: Export a snapshot of the current collection index.
docstring: Export a snapshot of the current collection index.
docstring_tokens: Export a snapshot of the current collection index .
code: def export_index(stream=None):
      """Export a snapshot of the current collection index."""
  
      es_index = collections.current().es_index
      with snapshot_repo() as (repo, repo_path):
          snapshot = f'{repo}/{es_index}'
          log.info('Elasticsearch snapshot %r', snapshot)
  
          log.info('Create snapshot')
          snapshot_resp = put_json(snapshot, {
              'indices': es_index,
              'include_global_state': False,
          })
          check_response(snapshot_resp)
  
          while True:
              status_resp = requests.get(snapshot)
              check_response(status_resp)
              state = status_resp.json()['snapshots'][0]['state']
              log.debug('Snapshot state: %r', state)
  
              if state == 'SUCCESS':
                  log.info('Snapshot created successfully')
                  break
  
              time.sleep(1)
  
          log.info('Create tar archive')
          subprocess.run(
              'tar c *',
              cwd=repo_path,
              shell=True,
              check=True,
              stdout=stream,
          )
code_tokens: def export_index ( stream = None ) : es_index = collections . current ( ) . es_index with snapshot_repo ( ) as ( repo , repo_path ) : snapshot = f'{repo}/{es_index}' log . info ( 'Elasticsearch snapshot %r' , snapshot ) log . info ( 'Create snapshot' ) snapshot_resp = put_json ( snapshot , { 'indices' : es_index , 'include_global_state' : False , } ) check_response ( snapshot_resp ) while True : status_resp = requests . get ( snapshot ) check_response ( status_resp ) state = status_resp . json ( ) [ 'snapshots' ] [ 0 ] [ 'state' ] log . debug ( 'Snapshot state: %r' , state ) if state == 'SUCCESS' : log . info ( 'Snapshot created successfully' ) break time . sleep ( 1 ) log . info ( 'Create tar archive' ) subprocess . run ( 'tar c *' , cwd = repo_path , shell = True , check = True , stdout = stream , )
short_docstring: Export a snapshot of the current collection index.
short_docstring_tokens: Export a snapshot of the current collection index .
comment: """Export a snapshot of the current collection index."""