# How to keep Database and Elasticsearch consistent using Logstash

**URL:** https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718
**Category:** Elasticsearch
**Created:** [November 21, 2018, 1:50pm UTC](https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718 "2018-11-21T13:50:27Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![patrick007](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@patrick007](https://discuss.elastic.co/u/patrick007)
#### Post date: [November 21, 2018, 1:50pm UTC](https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718/1 "2018-11-21T13:50:27Z")

</div>

I have a Relational database, I have used Logstash to migrate my Relational Postgres data to elasticsearch.

Now how can I keep my Database and Elasticsearch Server in sync?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 21, 2018, 2:27pm UTC](https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718/2 "2018-11-21T14:27:48Z")

</div>

I shared most of my thoughts there: [http://david.pilato.fr/blog/2015/05/09/advanced-search-for-your-legacy-application/](http://david.pilato.fr/blog/2015/05/09/advanced-search-for-your-legacy-application/)

Basically, I'd recommend modifying the application layer if possible and send data to elasticsearch in the same "transaction" as you are sending your data to the database.

---

<div class="post-metadata">

### Author: ![patrick007](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@patrick007](https://discuss.elastic.co/u/patrick007)
#### Post date: [November 21, 2018, 2:34pm UTC](https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718/3 "2018-11-21T14:34:57Z")

</div>

@dadoonet Is there any other way of doing it ?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 21, 2018, 3:16pm UTC](https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718/4 "2018-11-21T15:16:00Z")

</div>

Did you read my blog? The start of it at least?

---

<div class="post-metadata">

### Author: ![patrick007](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@patrick007](https://discuss.elastic.co/u/patrick007)
#### Post date: [November 22, 2018, 10:09am UTC](https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718/5 "2018-11-22T10:09:47Z")

</div>

@dadoonet Yes I had gone through it earlier. The blog is very helpful. It is great help

I was able to find the solution I used 'record\_last\_run' to record the last run the logstash and used the scheduler to check for changes in the Database

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 22, 2018, 10:58am UTC](https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718/6 "2018-11-22T10:58:15Z")

</div>

Awesome.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 20, 2018, 10:58am UTC](https://discuss.elastic.co/t/how-to-keep-database-and-elasticsearch-consistent-using-logstash/157718/7 "2018-12-20T10:58:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
