def take_snapshot(options):
    esm = ElasticsearchSnapshotManager(options)
    sh = esm.sh

    snapshot = options.snapshot and options.snapshot or 'all_' + time.strftime('%Y%m%d%H')

    snapdef = {
        "include_global_state": True
    }

    if options.indices:
        snapdef['indices'] = ','.join(options.indices)

    try:
        sh.create(repository=options.repository, snapshot=snapshot, body=json.dumps(snapdef), wait_for_completion=options.wait, request_timeout=7200)

        # Housekeeping - delete old snapshots
        snapshots = sh.get(repository=options.repository, snapshot="_all", request_timeout=120)['snapshots']
        num_snaps = len(snapshots)
        if num_snaps > options.keep:
            up_to = num_snaps - options.keep
            logger.info('TOTAL: %d - Will delete 1 -> %d' % (num_snaps, up_to + 1))
            for snap in snapshots[0:up_to]:
                sh.delete(repository=options.repository, snapshot=snap['snapshot'], request_timeout=3600)
                logger.info('Deleted snapshot %s' % snap['snapshot'])
    except exceptions.TransportError as e:
        pass