# Backup local database idea. Your thoughts?

**URL:** <https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482>\
**Category:** Questions about Thunkable X\
**Created:** [July 9, 2021, 12:18pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482 "2021-07-09T12:18:32Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![gene.arnold9d](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gene.arnold9d/32/86268_2.png) [@gene.arnold9d](https://community.thunkable.com/u/gene.arnold9d)\
**Post date:** [July 9, 2021, 12:18pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/1 "2021-07-09T12:18:32Z")

</div>

I just had some success with creating a simple method of backing up a local database. More work is needed and this would require a web service to actually store the data someplace, but I can build that stuff. My concern was how to get the data out of my Thunkable app and I think this will work. This very simple block arrangement will cycle through a local database and create a list from all the contents. Then convert that list to JSON which can be sent to wonderland. I would love your thoughts on this. I’m sure I’m not the first person doing this so I’m eager to learn from others.

 ![Screen Shot 2021-07-09 at 8.14.03 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/7/e7f97152ee3f99eb0c93569d153232bcf586720c.png)  
 ![Screen Shot 2021-07-09 at 8.14.15 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/2/f2184e568a875e4e0e0541159ca823ab8be747cd.png)

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [July 9, 2021, 12:55pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/2 "2021-07-09T12:55:43Z")

</div>

That looks like a straightforward way to store the data and makes use of Thunkable’s own JSON parsing so it’s pretty block efficient.

If you need a suggestion for where on the cloud to store it, you might consider using Firebase - have your users log in so each one has their own data storage, then store that JSON in Firebase under each user’s ID.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [July 9, 2021, 1:17pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/3 "2021-07-09T13:17:51Z")

</div>

`Local Data` in Thunkable is formatted as **table** so if I want to take a copy I would connect Google sheet and go through the records in the `Local Data` to **append** them into my Google sheet.

---

<div class="post-metadata">

**Author:** ![gene.arnold9d](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gene.arnold9d/32/86268_2.png) [@gene.arnold9d](https://community.thunkable.com/u/gene.arnold9d)\
**Post date:** [July 9, 2021, 1:47pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/4 "2021-07-09T13:47:53Z")

</div>

I agree and that would be great for just me but that won’t work for others because I don’t see any way for you to create a connection to a personal Google Sheet on the fly correct? The issue I’m trying to solve is that when a new release of my app comes out the users can back up their data. I need this data to be local to the phone and not in the cloud. This is for mountain bikers and we do not always have access to internet where we are setting up out bikes. Is there a way for a user to create their own Google Sheet connection? That would be cool if they could and would save me from having to create any services. Please share 🙂

---

<div class="post-metadata">

**Author:** ![gene.arnold9d](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gene.arnold9d/32/86268_2.png) [@gene.arnold9d](https://community.thunkable.com/u/gene.arnold9d)\
**Post date:** [July 9, 2021, 1:52pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/5 "2021-07-09T13:52:30Z")

</div>

That might be an option. It might also be a few more steps then my mountain biker folks will take. I was going to try this approach.

- Have a button that says “SMS your Backup ID” and a text box for the phone number (could do the same thing with email so just not sure)
- When ID arrives you copy it.
- Another text box for you to paste that Id and another button that says “Back up”  
When you push the back up button it pushes the data to an online database using that ID to flag the data just for that user.

Now I have a way to store data for specific users pretty easily and they can restore the data by simply passing that id back up to another service.

Thoughts?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [July 9, 2021, 1:52pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/6 "2021-07-09T13:52:48Z")

</div>

In this case, you can store the data as a `stored variable` in the phone but it will only be accessed by the app.

Alternatively, allow the user to store the file as .txt local in the phone. You can use a variation of my app **Export to vCard** to accomplish it.

Here is a [link to Export to vCard](https://x.thunkable.com/projectPage/60a172a49d5e640011cd9947)

---

<div class="post-metadata">

**Author:** ![gene.arnold9d](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gene.arnold9d/32/86268_2.png) [@gene.arnold9d](https://community.thunkable.com/u/gene.arnold9d)\
**Post date:** [July 9, 2021, 1:54pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/7 "2021-07-09T13:54:41Z")

</div>

Oh that sounds promising! I didn’t know we could read flat files off the phone’s storage. Thank you!

---

<div class="post-metadata">

**Author:** ![gene.arnold9d](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gene.arnold9d/32/86268_2.png) [@gene.arnold9d](https://community.thunkable.com/u/gene.arnold9d)\
**Post date:** [July 9, 2021, 2:01pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/8 "2021-07-09T14:01:09Z")

</div>

I like that vCard example. So you’re using a service you created up on GitHub to create the card file and since you are trying to open it as a link the default open for the file type kicks in. Very cool indeed!

---

<div class="post-metadata">

**Author:** ![gene.arnold9d](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gene.arnold9d/32/86268_2.png) [@gene.arnold9d](https://community.thunkable.com/u/gene.arnold9d)\
**Post date:** [July 9, 2021, 2:01pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/9 "2021-07-09T14:01:57Z")

</div>

Now, is it possible for an app to read from that file? I thought I saw an option in the list object to create a list from a csv so I’m thinking yes.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [July 9, 2021, 2:16pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/10 "2021-07-09T14:16:25Z")

</div>

> [@gene.arnold9d](#):
>
> So you’re using a service you created up on GitHub to create the card file

I chose to place it in GitHub but you can have it anywhere including the phone storage itself as long as you have the path to run it.

You van have it as part of your assets if you wish.

---

<div class="post-metadata">

**Author:** ![gene.arnold9d](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gene.arnold9d/32/86268_2.png) [@gene.arnold9d](https://community.thunkable.com/u/gene.arnold9d)\
**Post date:** [July 9, 2021, 2:18pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/11 "2021-07-09T14:18:57Z")

</div>

But how would I now read this file and restore the database from it?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [July 9, 2021, 2:22pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/12 "2021-07-09T14:22:44Z")

</div>

The `web API` will read the file and if you store it originally as JSON then you will be able to work with it just like any `response` from API calls.

---

<div class="post-metadata">

**Author:** ![gene.arnold9d](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gene.arnold9d/32/86268_2.png) [@gene.arnold9d](https://community.thunkable.com/u/gene.arnold9d)\
**Post date:** [July 9, 2021, 2:31pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/13 "2021-07-09T14:31:21Z")

</div>

Understood. So some web services will be needed to pull this off.

- Create a service to build a JSON file that can be stored locally to the phone
- Create a service that can take the local file, read it and send back the data for the web api to use and create a database from.

Would you mind outlining the process please on how this would work? I don’t really need the code but more the process because I’m still not sure what can be done.

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [July 9, 2021, 2:38pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/14 "2021-07-09T14:38:14Z")

</div>

You might have a look at this project for the second part.

> [@Read Text Files Directly into Thunkable](https://community.thunkable.com/t/read-text-files-directly-into-thunkable/1042037):
>
> Statment of the problem As others have [discussed](http://community.thunkable.com/t/thunkable-x-reading-file-from-txt/931562), there is no native way to import a text file into Thunkable. Using the Webviewer Component and [Thunkable(ReactNative) WebExtension](https://docs.thunkable.com/web-viewer) I was able to create a file upload feature with a simple HTML file hosted on the Firebase’s free Web Hosting Setup You could do this on any hosting site. But experienced Thunkers will already have a free Firebase account. Just enable hosting and you now have a site. I set up the site following by [deploying hostin…](http://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [July 9, 2021, 2:47pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/15 "2021-07-09T14:47:24Z")

</div>

> [@catsarisky](#):
>
> You might have a look at this project for the second part.

This is more complicated than needed. Just add `Web API` component and pass the file path to it. the green `response` would be the content of the text file.

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [July 9, 2021, 2:49pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/16 "2021-07-09T14:49:05Z")

</div>

> [@muneer](#):
>
> Just add `Web API` component and pass the file path to it. the green `response` would be the content of the text file.

Cool, thanks @muneer! I learned something new today. 🙂

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:19pm UTC](https://community.thunkable.com/t/backup-local-database-idea-your-thoughts/1387482/17 "2024-11-08T13:19:49Z")

</div>


