Clone database into another

I have a development application cloned from my production environment. When I do that, only the database structure is cloned.

Is there a way to copy everything (the structure AND the data) from a database to another one?

If you made the clone via a clone link, it should already have copied the contents of the data tables. Did you make the clone in some other way?

Say, for example, you are using an app-server deployment, you can download your tables and use an uplink script to populate. I’ve done this a lot, it’s dead easy.

1 Like

I read the question as being about two databases within the same app, in the Anvil IDE, with Anvil cloud deployment. But I think the answer may be the same as what @socint suggests—which sounds tedious and non-obvious to me, not having done it before. But I recall some old forum posts about backing up and restoring data tables that may be helpful in this regard.

@jshaffstall I don’t want to clone the application again. Last time we did, it took days until we get something usable and it required us to get some internal help from Anvil. We have a lot of images inside the database and this makes things more difficult.

@socint I know about the CSV export. It is not “dead easy”, if you have ~20 tables, gigabytes of data with images inside some of the tables that are not exported in CSV (guess what, your “dead easy” solution doesn’t work for that scenario), if you have to do it manually and still trying to keep the relationship between data.

@hugetim yes, I found some answers there. It would be great if there is something official. But apparently I will need to rely on workarounds that may not work properly. Thanks for answering that.

1 Like

Jay asked why cloning didn’t copy the data, and you replied you don’t want to do it, rather than answering to the why question.

Something is missing here, and it’s difficult to answer a question without all the information required.

Are you moving an application from Anvil hosted servers to your own server, and running the app with anvil-app-server, or are you cloning the app and continuing to host it at anvil.works?

…or are you talking about creating a new database within an Anvil app?

For the latter two cases, I have a potential idea, albeit one with some manual steps. You could temporarily share the original, existing tables with your new database. Then use server code to copy the data from the original tables into the new tables (using add_rows to batch things, memory permitting). Once all the data has been copied over from the original, shared tables to the new tables; you can remove the shared tables from the new database.

No need to be rude, to be honest. We are all here just trying to help.

Sounds to me like you need to look at an external database option. There’s a tutorial or two for this, that you can look up.

1 Like

I don’t want to clone the application because I already did it before. I don’t need the entire application again. I just need the data from one database (the production one) to another database (the development one). Code between the development application and production application are already synchronized.

2 Likes

Saying that something is “dead easy” is being rude to me. Maybe I didn’t share my context entirely so people could help me, but a thing that I learned in the years, as you can never assume that something is easy for the other person.

1 Like

I am not cloning the application. I already did that before. What I want is to have the production database from one application to be cloned to a development database in another application (the code from both applications are synchronized)

You are completely missing the point of the questions that have been asked. Nobody suggested you clone the application again. You were asked,

How did you clone the application in the first place? You have never said, and for anyone to help you you need to provide details.

Did you use the a clone link?

Did you use git and push it into a new application?

Did you do something else?

Again, you didn’t answer the question.

Oh well, good luck finding help.