# How can i move index files to another path without stop the es service

**URL:** <https://discuss.elastic.co/t/how-can-i-move-index-files-to-another-path-without-stop-the-es-service/17228>\
**Category:** Elasticsearch\
**Created:** [April 28, 2014, 9:44am UTC](https://discuss.elastic.co/t/how-can-i-move-index-files-to-another-path-without-stop-the-es-service/17228 "2014-04-28T09:44:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![meilian\_zhu](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@meilian\_zhu](https://discuss.elastic.co/u/meilian_zhu)\
**Post date:** [April 28, 2014, 9:44am UTC](https://discuss.elastic.co/t/how-can-i-move-index-files-to-another-path-without-stop-the-es-service/17228/1 "2014-04-28T09:44:27Z")

</div>

my local disk is very small,just can store one day index files.So i wanted  
to move my index file to another fs path.  
This is my sh.It excute everyday.  
#!/bin/bash  
#copy the index files form elasticsearch to clusterFS now  
ddate=`date -d "1 days ago" +%Y.%m.%d`  
clustername="mams\_online\_log"  
indexdir="/data/soft/logmonitor/elasticsearch-1.1.0/data"  
ipip=$(hostname)  
dstdir=/mnt/lego-log/$ipip  
echo "Start time: $(date "+%Y.%m.%d %H:%M:%S")"  
echo "$dstdir"

# copy the old index file;

mkdir $dstdir  
cp -r $indexdir/$clustername/nodes/0/indices/logstash-$ddate $dstdir/  
mv $indexdir/$clustername/nodes/0/indices/logstash-$ddate  
$indexdir/$clustername/nodes/0/indices/tmp  
ln -s $dstdir/logstash-$ddate  
$indexdir/$clustername/nodes/0/indices/logstash-$ddate  
rm -rf $indexdir/$clustername/nodes/0/indices/tmp  
echo "ok"  
echo "End time: $(date "+%Y.%m.%d %H:%M:%S")"

But when i "lsof" this is always so many files used by the es pid.  
So how i can do for this ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ca99a71c-3524-4d8d-9c68-a21337aba62c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ca99a71c-3524-4d8d-9c68-a21337aba62c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Michael\_Salmon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_salmon/32/5330_2.png) [@Michael\_Salmon](https://discuss.elastic.co/u/Michael_Salmon)\
**Post date:** [April 28, 2014, 12:18pm UTC](https://discuss.elastic.co/t/how-can-i-move-index-files-to-another-path-without-stop-the-es-service/17228/2 "2014-04-28T12:18:52Z")

</div>

Basically you can't do with no stop at all. ES holds indexes open so that  
it can access the data quickly. You could close the index, copy the data  
and then open the index again but it is probably best to stop es, move the  
data, change the data path and then start es again. You can have multiple  
data paths so that you can skip the copying but you need to restart es.

/Michael

On Monday, 28 April 2014 11:44:27 UTC+2, meilian zhu wrote:

> my local disk is very small,just can store one day index files.So i wanted  
> to move my index file to another fs path.  
> This is my sh.It excute everyday.  
> #!/bin/bash  
> #copy the index files form elasticsearch to clusterFS now  
> ddate=`date -d "1 days ago" +%Y.%m.%d`  
> clustername="mams\_online\_log"  
> indexdir="/data/soft/logmonitor/elasticsearch-1.1.0/data"  
> ipip=$(hostname)  
> dstdir=/mnt/lego-log/$ipip  
> echo "Start time: $(date "+%Y.%m.%d %H:%M:%S")"  
> echo "$dstdir"
> 
> # copy the old index file;
> 
> mkdir $dstdir  
> cp -r $indexdir/$clustername/nodes/0/indices/logstash-$ddate $dstdir/  
> mv $indexdir/$clustername/nodes/0/indices/logstash-$ddate  
> $indexdir/$clustername/nodes/0/indices/tmp  
> ln -s $dstdir/logstash-$ddate  
> $indexdir/$clustername/nodes/0/indices/logstash-$ddate  
> rm -rf $indexdir/$clustername/nodes/0/indices/tmp  
> echo "ok"  
> echo "End time: $(date "+%Y.%m.%d %H:%M:%S")"
> 
> But when i "lsof" this is always so many files used by the es pid.  
> So how i can do for this ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0a0464a5-0fad-4522-8c86-8d96f2311339%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0a0464a5-0fad-4522-8c86-8d96f2311339%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kyle\_Lin](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@Kyle\_Lin](https://discuss.elastic.co/u/Kyle_Lin)\
**Post date:** [May 7, 2014, 8:21am UTC](https://discuss.elastic.co/t/how-can-i-move-index-files-to-another-path-without-stop-the-es-service/17228/3 "2014-05-07T08:21:17Z")

</div>

How about closing index before moving files? Does it fit your need?

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

meilian zhu於 2014年4月28日星期一UTC+8下午5時44分27秒寫道：

> my local disk is very small,just can store one day index files.So i wanted  
> to move my index file to another fs path.  
> This is my sh.It excute everyday.  
> #!/bin/bash  
> #copy the index files form elasticsearch to clusterFS now  
> ddate=`date -d "1 days ago" +%Y.%m.%d`  
> clustername="mams\_online\_log"  
> indexdir="/data/soft/logmonitor/elasticsearch-1.1.0/data"  
> ipip=$(hostname)  
> dstdir=/mnt/lego-log/$ipip  
> echo "Start time: $(date "+%Y.%m.%d %H:%M:%S")"  
> echo "$dstdir"
> 
> # copy the old index file;
> 
> mkdir $dstdir  
> cp -r $indexdir/$clustername/nodes/0/indices/logstash-$ddate $dstdir/  
> mv $indexdir/$clustername/nodes/0/indices/logstash-$ddate  
> $indexdir/$clustername/nodes/0/indices/tmp  
> ln -s $dstdir/logstash-$ddate  
> $indexdir/$clustername/nodes/0/indices/logstash-$ddate  
> rm -rf $indexdir/$clustername/nodes/0/indices/tmp  
> echo "ok"  
> echo "End time: $(date "+%Y.%m.%d %H:%M:%S")"
> 
> But when i "lsof" this is always so many files used by the es pid.  
> So how i can do for this ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2590b704-6e43-4166-bbbc-6ec36b29adca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2590b704-6e43-4166-bbbc-6ec36b29adca%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:31am UTC](https://discuss.elastic.co/t/how-can-i-move-index-files-to-another-path-without-stop-the-es-service/17228/4 "2017-07-06T01:31:08Z")

</div>


