Clone (update latest changes) in new remote DB in DB Manager on new remote Docker

To backup the full db structure and data from the local docker dev database and reapply it on the live remote docker follow the following steps:

WARNING: this should be only performed on empty new Live target!! Otherwise you will loose your existing live database.

  1. Switch to your local docker target and click on “Save Database Data and Structure” icon

image

  1. Open your project folder in Finden/Windows Explorer and copy the file db_save.sql from the Local Docker folder db_init to your Live Docker target folder db_init - make sure there are no other sql files in it!

image

  1. Switch to the Live target (1), shudown the Services if running (2) and then launch them (3) - this will build the database with the backup data and structure you saved from the local dev

image

6 Likes

I think this would be very useful.

1 Like

I can see this being hugeley beneficial @George - this would allow for the entire db structure to be setup on dev, work with it - then when ready, simply clone the db structure to staging and production - as it’s typical to work with different data in those environments, so cloning the data isn’t so much of a requirement for me.

You guys know that you can do that already right? No need to wait for Wappler to implement it.

For mysql you can just use mysqldump command or the UI of the workbench app.

https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html

And for PostgreSQL you can use pg_dump command or a UI like pgAdmin.

Or use the docker method I mentioned above:

1 Like

3 posts were split to a new topic: Improve Database Manager with existing schema changes synchronization

@George when I go to production I’ll most likely move outside of the MySql provided within my Docker Container to a managed DB.

I was wondering if the db_init/db_save.sql would be a way I can clone the schema to a new remote DB that’s not within Wappler? would it work the same way?

Yes but you should just use the database manager and apply the changes on the new target. That is the official way.

The db_init way is for docker only and is just for full backups and as a last resort.

This is also the method I use. I found it as a solution myself in this bug thread. It’s not ideal, but it works. I think for new users it’s really frustrating if this doesn’t work when you want to deploy to live, so better instructions for this in the documentation instead of on the forum would be welcome I suppose. Maybe a copy db structure and data to/from target-functionality would be a good (temporary) solution too.

Unfortunately, if you remember some of the change history is deleted so if I take the official approach it won’t recreate the entire db the same.

But with Mac where is the db_save.sql file?

Hi George.
your suggestion is unfortunately impossible for me to implement
Maybe because I don’t use Windows, but MacOS, I can save the database correctly (I receive confirmation from the program) but then I can’t understand where and how to view the .wappler directory
Or maybe I’m the one who didn’t understand how to do it?
Setting up a site in NodeJS with Wappler and Docker on Hetzner is fantastic and really fast (I have already set up 3 projects) but if I can’t import the data contained in the old databases, I get stuck.

the .wappler folder is hidden. You need to enable hidden files and folders in Finder or in Wappler File Manager - right click in Wapper File Manager and select “Show Hidden” to see it.

1 Like

Thank You

Hello Teodor
I tried but it doesn’t work for me
1- in Local mode I export the database (db_save.sql) from wappler
Schermata 2021-04-05 alle 18.45.19
2- load the file in the PC and modify the database by adding tables and contents
3- I create new sql file and name it db_save.sql
4- I substitute the one exported by Wappler
5- transfer the file to the db_ folder as shown in the image


6- In Production mode I click deploy
Schermata 2021-04-05 alle 19.05.19
But the database was not changed

After countless attempts, I was finally able to load a database with all the tables and all the data contained, taking it from an external database (dump * .sql)
I had to rename the dump file * .sql to db_save.sql, correct the header lines with the editor (copying them from the backup file db_save.sql), and then install it both locally and remotely
Then I restarted Wappler and Docker

I just found out that if you want to switch / migrate from a PHP project to a Nodejs project; you can use this exact method to migrate your database easily from your PHP project to your Nodejs project.

Awesome! :grin: :grin: :grin:

Hi everybody,
@George > Do you know if and how it’s possible to copy from production target to the local one.
I lost some of my changes files, my production DB is uptodate when my local DB is an old schema one.
Many thanks .

Yes you can just choose in the file manager to connect to remote and then download the files you need.

Thanks for your previous answer, i copy-pasted all the files I needed from the remote target (mostly views and SC).

  • Is it possible to get the migrations files from the remote target?
  • How could I copy-paste the production DB to local remote?
    Thanks