0

*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?

Ben
  • 23
  • 4

2 Answers2

0

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.

Phill W.
  • 1,479
  • 7
  • 7
0

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.

Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
  • thanks mate. question updated :) – Ben May 07 '22 at 02:53
  • 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. – Mark Wagner May 10 '22 at 00:41