# Avoid reinventing a reindexing toolbox

**URL:** <https://discuss.elastic.co/t/avoid-reinventing-a-reindexing-toolbox/309273>\
**Category:** Elasticsearch\
**Created:** [July 10, 2022, 8:43pm UTC](https://discuss.elastic.co/t/avoid-reinventing-a-reindexing-toolbox/309273 "2022-07-10T20:43:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefws](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefws/32/6442_2.png) [@stefws](https://discuss.elastic.co/u/stefws)\
**Post date:** [July 10, 2022, 8:43pm UTC](https://discuss.elastic.co/t/avoid-reinventing-a-reindexing-toolbox/309273/1 "2022-07-10T20:43:05Z")

</div>

Anyone know of a good CLI toolbox for doing reindexing to save #shards?

Or should I create my own set of REST API scripts for this from scratch, surely someone else should have had the same issue before 🙂

EDIT: Created a few scripts to suit my purpose, maybe they can help others, if interested take a peak on [my github](https://github.com/stefws/elastic-clis.git)

Example of usage could be like:

```auto
# Make sure you got your templads in place prior to reindexing,
# eg. same mapping but different index pattern matching
# (in my case I use: systemlog-* vs systemlog.*)

# batch reindexing January indicies into a yearly one
esapi-catindex -p 'systemlog-2022.01.*' | sort -k3 | awk '/-2022/{print $3}' | 
  while read idx; do
      echo $idx...
      es-reindex -L /tmp/reindx-systemlog.log -a -r 250 -s $idx -D systemlog.2022
  done

```

One can then make a cron job to run nightly after index roll-over pit and reindex either yesterday's index or todate-90days or what ever is desired 🙂

---

<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:** [August 7, 2022, 8:43pm UTC](https://discuss.elastic.co/t/avoid-reinventing-a-reindexing-toolbox/309273/2 "2022-08-07T20:43:33Z")

</div>

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