Score:0

Add to mysql db instead of restore

ru flag
Ben

*EDIT/UPDATE I have an RPI4 with mysql. I need to collect all the data from the "zm" database, and ADD it to another database of the same name on another server, so NO data on the 2nd server is removed/overwritten.

This will occur once per day, when the rpi is on the same wifi network


ORIGINAL I have an automatic backup of a database (server1), which is then sent to another server(sever2). My requirement is for the backup to be added to the database on server2, rather than a restore/clone... I hope this makes sense..

Any ideas?

Score:0
cn flag

That's not what a Backup is for.

A Backup is something that you can use to reliably recreate your database if your database, or the server it sits on, goes "Boom!". As such, it really is "All or Nothing"; You restore the whole thing at once. (OK, mysqldump can give you different formats that you can muck about with, but the principal is "Backup .. Restore" everything).

Sounds to me that you want some sort of Data Replication between the two databases.

Score:0
vn flag

It is unclear what you are trying to accomplish (or if dumping is even the right tool) but when you dump the database do not use --add-drop-database, --add-drop-table, --add-drop-trigger. This will result in existing data on server2 remaining. Do use --no-create-db, --no-create-info, --no-tablespaces (unless of course the dump contains databases and tables that do not exist on server2). This will allow the restore to not error out by trying to create a database or table that already exists on server2.

Ben avatar
ru flag
Ben
thanks mate. question updated :)
vn flag
You should probably use replication for this task, unless you don't want updates/deletes run on server1 to get executed on server2 as well. Nonetheless using all the switches in my answer should accomplish the goal, if awkwardly.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.