# VM history cleanup

**URL:** <https://forum.opennebula.io/t/vm-history-cleanup/1037>\
**Category:** Product Support\
**Created:** [July 27, 2015, 11:24am UTC](https://forum.opennebula.io/t/vm-history-cleanup/1037 "2015-07-27T11:24:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ondrej\_hamada](https://avatars.discourse-cdn.com/v4/letter/o/ea5d25/32.png) [@ondrej\_hamada](https://forum.opennebula.io/u/ondrej_hamada)\
**Post date:** [July 27, 2015, 11:24am UTC](https://forum.opennebula.io/t/vm-history-cleanup/1037/1 "2015-07-27T11:24:30Z")

</div>

Hello guys,  
is it possible (allowed) to do a cleanup of deleted VMs from database? Currently, each VM that has ever run in Nebula has its record in database. Additionally there is a history table witch records for each VM as well. And the contextualization data are stored in oneadmin’s home in ‘vms’ directory also.

Because our environment is quite dynamic, we have only about 1000 VMs, but their IDs are around 530k - what means there are more than 500k non-needed entries in DB. It makes the DB big and slows down the queries.

Could I delete the records from DB and from the ‘vms’ directory or does Nebula need them (because of generating next VM ID or stuff like that)? I’m not worried about accounting since I don’t need it at all.

---

<div class="post-metadata">

**Author:** ![lorenzo\_faleschini](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/lorenzo_faleschini/32/4242_2.png) [@lorenzo\_faleschini](https://forum.opennebula.io/u/lorenzo_faleschini)\
**Post date:** [July 27, 2015, 4:55pm UTC](https://forum.opennebula.io/t/vm-history-cleanup/1037/2 "2015-07-27T16:55:31Z")

</div>

> [@ondrej\_hamada](#):
>
> Could I delete the records from DB and from the ‘vms’ directory or does Nebula need them (because of generating next VM ID or stuff like that)? I’m not worried about accounting since I don’t need it at all.

you can safely delete them (both files in log folder and entries in vm\_monitoring table… if you want to hardcore clean you can delete all entries also in host\_monitoring and history too) ,

the “next id” is stored in the pool\_control table

just have a backup before doing this, just in case

stop one  
backup  
delete records in tables and logs in folder  
start one

test  
enjoy

PS: this is something I do on regular basis in production environments… but may not be a best practice. Never had a problem with it anyway.

---

<div class="post-metadata">

**Author:** ![ondrej\_hamada](https://avatars.discourse-cdn.com/v4/letter/o/ea5d25/32.png) [@ondrej\_hamada](https://forum.opennebula.io/u/ondrej_hamada)\
**Post date:** [August 3, 2015, 12:28pm UTC](https://forum.opennebula.io/t/vm-history-cleanup/1037/3 "2015-08-03T12:28:40Z")

</div>

thanks lorenzo

so far i’ve cleaned up only vm\_pool and i’ve also adujsted my db backup script to omit history table, but it seems good

---

<div class="post-metadata">

**Author:** ![ruben](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ruben/32/19_2.png) [@ruben](https://forum.opennebula.io/u/ruben)\
**Post date:** [August 5, 2015, 10:29am UTC](https://forum.opennebula.io/t/vm-history-cleanup/1037/4 "2015-08-05T10:29:20Z")

</div>

This is quite interesting, we will evaluate its implementation for the next  
version. Thanks!

[http://dev.opennebula.org/issues/150](http://dev.opennebula.org/issues/150)

(there was an old request for this but it was closed during an issue  
cleanup)
