Thread overview
Mysql-native - full database backup
Jan 02, 2017
Geert
Jan 05, 2017
crimaniak
Jan 05, 2017
Geert
Jan 05, 2017
Daniel Kozák
Jan 05, 2017
Geert
January 02, 2017
Hi!

How can i create a full database backup using mysql-native for D?

https://github.com/mysql-d/mysql-native


Thanks!
January 05, 2017
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?
January 05, 2017
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);
January 05, 2017
Geert via Digitalmars-d-learn <digitalmars-d-learn@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);
}




January 05, 2017
On Thursday, 5 January 2017 at 21:47:55 UTC, Daniel Kozák wrote:
> Geert via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsal Čt, led 5, 2017 v 3∶13 :
>> [...]
>
> [...]

Nice function. Thanks!