Mysql-native - full database backup
Daniel Kozák via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 5 13:47:55 PST 2017
Geert via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
napsal Čt, led 5, 2017 v 3∶13 :
> On Thursday, 5 January 2017 at 01:16:09 UTC, crimaniak wrote:
>> On Monday, 2 January 2017 at 15:29:08 UTC, Geert wrote:
>>> Hi!
>>>
>>> How can i create a full database backup using mysql-native for D?
>> Too common question. Do you have problems with driver usage? Do you
>> have problems with database backup schema?
>
> 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);
Yep, usin mysqldump is fine I've been using it for a quite time now
void synchronizeDatbase(string host, string port, string portDst,
string dbName)
{
import std.process: spawnShell, wait;
writefln("Host: %s, DB: %s", host, dbName);
auto pid = spawnShell("mysqldump --max_allowed_packet=1024M -C -h "
~ host ~ " -P" ~ port ~
" -u" ~ credentials.user ~ " -p" ~
credentials.pwd ~
" -R --add-drop-database --skip-triggers
--ignore-table=cars.history -B " ~ dbName ~ " |" ~
" mysql -u" ~ credentials.user ~ " -p" ~
credentials.pwd ~
" -h 127.0.0.1 -P" ~ portDst);
wait(pid);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20170105/c868b7c7/attachment.html>
More information about the Digitalmars-d-learn
mailing list