# How to archive a SQLite database

**URL:** <https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083>\
**Category:** General\
**Tags:** database\
**Created:** [4 November 2022 11:16 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083 "2022-11-04T11:16:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parowek](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@Parowek](https://discourse.nodered.org/u/Parowek)\
**Post date:** [4 November 2022 11:16 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/1 "2022-11-04T11:16:50Z")

</div>

Hello  
I have an SQLite databese in which i save temperature and humidity data with timestamps (epoch). I want to archive the databse by months. So that when november ends my data gets saved to another database for december etc. How can i achieve that?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 November 2022 12:19 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/2 "2022-11-04T12:19:58Z")

</div>

Have you considered using something like Influxdb rather than sqlite? Then you can always have previous months instantly accessible.

Alternatively you can use one of the timer nodes, node-red-contrib-cron-plus is my favourite, to give you an event at the start of each month which you can use to do the database archive.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [4 November 2022 14:03 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/3 "2022-11-04T14:03:27Z")

</div>

> [@Parowek](#):
>
> data with timestamps (epoch)

Is that defined as a datetime field in the DB? If so you can do a simple query on date to extract the data to a different DB. Then a delete query using the same date/time spec.

> [@Parowek](#):
>
> So that when november ends my data gets saved to another database for december etc.

But as Colin says, InfluxDB is designed from the ground up to handle this. You can specify a retention policy to continuously trim the data along with a "continuous query" to copy the data to another db. You can also summarise the data to the 2nd db. So I keep sensor data at a per-minute level for a week and summarise to hourly data which I keep for a few years.

---

<div class="post-metadata">

**Author:** ![Parowek](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@Parowek](https://discourse.nodered.org/u/Parowek)\
**Post date:** [4 November 2022 16:10 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/4 "2022-11-04T16:10:13Z")

</div>

Well I’m a total newbie in database systems so I have no idea about how InfluxDB works. Guess I’ll have to find out. Thanks

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [4 November 2022 16:46 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/5 "2022-11-04T16:46:32Z")

</div>

This might help a little 🙂

[How to effectively use InfluxDB - FAQs - Node-RED Forum (nodered.org)](https://discourse.nodered.org/t/how-to-effectively-use-influxdb/36885/5)

---

<div class="post-metadata">

**Author:** ![Parowek](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@Parowek](https://discourse.nodered.org/u/Parowek)\
**Post date:** [5 November 2022 16:50 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/6 "2022-11-05T16:50:06Z")

</div>

But influxDB free plan allows to store data only for 30 days, am I right?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 November 2022 17:01 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/7 "2022-11-05T17:01:27Z")

</div>

No, you want InfluxDB server. Self-hosted. No limits.

---

<div class="post-metadata">

**Author:** ![Parowek](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@Parowek](https://discourse.nodered.org/u/Parowek)\
**Post date:** [7 November 2022 06:57 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/8 "2022-11-07T06:57:03Z")

</div>

InfluxDB website literally says “server less”.  
I think I’m missing something

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 November 2022 07:27 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/9 "2022-11-07T07:27:26Z")

</div>

> [@Parowek](#):
>
> InfluxDB website literally says “server less"

Can you give us a link to that please?

---

<div class="post-metadata">

**Author:** ![Parowek](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@Parowek](https://discourse.nodered.org/u/Parowek)\
**Post date:** [7 November 2022 08:16 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/10 "2022-11-07T08:16:21Z")

</div>

Nevermind, I had to be on InfluxDB Cloud website.  
Anyway, i downloaded InfluxDB and hope to sort it out soon.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 November 2022 08:16 UTC](https://discourse.nodered.org/t/how-to-archive-a-sqlite-database/70083/11 "2022-11-21T08:16:55Z")

</div>

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