Geert via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsal Čt, led 5, 2017 v 3∶13 :<br>
<blockquote type="cite"><div class="plaintext" style="white-space: pre-wrap;">On Thursday, 5 January 2017 at 01:16:09 UTC, crimaniak wrote:
<blockquote>On Monday, 2 January 2017 at 15:29:08 UTC, Geert wrote:
<blockquote>Hi!

How can i create a full database backup using mysql-native for D?
</blockquote> Too common question. Do you have problems with driver usage? Do you have problems with database backup schema?
</blockquote>
Sorry for not being specific, my english it's not quite good. I thought i could use a specific mysql-native method (like "execProcedure") for making database backups, but it seems it doesn't have it.

Anyway, i ended up using mysqldump with executeShell function:

string query = "mysqldump -uroot -ptest_pass test_db > /home/user/mydb_backup.sql";
executeShell(query);


For those who use lampp:

string query = "/opt/lampp/bin/mysqldump -uroot -ptest_pass test_db > /home/user/mydb_backup.sql";
executeShell(query);</div></blockquote><br><div>Yep, usin mysqldump is fine I've been using it for a quite time now</div><div><br></div><div>void synchronizeDatbase(string host, string port, string portDst, string dbName)</div><div>{</div><div>    import std.process: spawnShell, wait;</div><div><br></div><div>    writefln("Host: %s, DB: %s", host, dbName);</div><div>    auto pid = spawnShell("mysqldump --max_allowed_packet=1024M -C -h " ~ host ~ " -P" ~ port ~</div><div>                          " -u" ~ credentials.user ~ " -p" ~ credentials.pwd ~</div><div>                          " -R --add-drop-database --skip-triggers --ignore-table=cars.history -B " ~ dbName ~ " |" ~</div><div>                          " mysql -u" ~ credentials.user ~ " -p" ~ credentials.pwd ~</div><div>                          " -h 127.0.0.1 -P" ~ portDst);</div><div>    wait(pid);</div><div>}</div><div><br></div>