NDrive / graylog-archiver

Archives graylog indices.
MIT License
13 stars 6 forks source link

Elasticsearch create backup repository fails if directory exists #5

Closed andrefreitas closed 7 years ago

andrefreitas commented 7 years ago

In version 0.1.3, if the backup directory exists (eg. graylog_0), the backup fails.

In this example, the graylog_0 directory already exists in the backup directory:


2017-08-29 15:54:25,777 [INFO] Indices: ['graylog_1', 'graylog_0', 'graylog_3', 'graylog_2']
2017-08-29 15:54:25,781 [INFO] Archiving ['graylog_2', 'graylog_1', 'graylog_0']
2017-08-29 15:54:25,781 [INFO] Archiving graylog_2...
2017-08-29 15:54:25,781 [INFO] Dumping from elasticsearch...
2017-08-29 15:54:26,978 [INFO] Compressing directory...
2017-08-29 15:54:27,020 [INFO] Archived at /srv/containers/elasticsearch_backups/graylog_2.tar.gz
2017-08-29 15:54:27,020 [INFO] Archiving graylog_1...
2017-08-29 15:54:27,020 [INFO] Dumping from elasticsearch...
PUT http://localhost:9201/_snapshot/573438b666194dd895d099153410298d/snapshot [status:400 request:0.009s]
Traceback (most recent call last):
  File "/Users/afreitas/dev/github/graylog-archiver/.env/bin/graylog-archiver", line 11, in <module>
    load_entry_point('graylog-archiver', 'console_scripts', 'graylog-archiver')()
  File "/Users/afreitas/dev/github/graylog-archiver/graylog_archiver/cli.py", line 33, in main
    archiver.archive()
  File "/Users/afreitas/dev/github/graylog-archiver/graylog_archiver/graylog_archiver.py", line 25, in archive
    dump_dir = self.graylog.dump(index)
  File "/Users/afreitas/dev/github/graylog-archiver/graylog_archiver/graylog_elasticsearch.py", line 60, in dump
    {"indices": index}
  File "/Users/afreitas/dev/github/graylog-archiver/.env/lib/python3.6/site-packages/elasticsearch-5.2.0-py3.6.egg/elasticsearch/client/utils.py", line 73, in _wrapped
  File "/Users/afreitas/dev/github/graylog-archiver/.env/lib/python3.6/site-packages/elasticsearch-5.2.0-py3.6.egg/elasticsearch/client/snapshot.py", line 22, in create
  File "/Users/afreitas/dev/github/graylog-archiver/.env/lib/python3.6/site-packages/elasticsearch-5.2.0-py3.6.egg/elasticsearch/transport.py", line 318, in perform_request
  File "/Users/afreitas/dev/github/graylog-archiver/.env/lib/python3.6/site-packages/elasticsearch-5.2.0-py3.6.egg/elasticsearch/connection/http_urllib3.py", line 128, in perform_request
  File "/Users/afreitas/dev/github/graylog-archiver/.env/lib/python3.6/site-packages/elasticsearch-5.2.0-py3.6.egg/elasticsearch/connection/base.py", line 122, in _raise_error
elasticsearch.exceptions.RequestError: TransportError(400, 'invalid_snapshot_name_exception', '[573438b666194dd895d099153410298d:snapshot] Invalid snapshot name [snapshot], snapshot with such name already exists')
(.env)```