www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Mysql-native - full database backup

reply Geert <gerndz gmail.com> writes:
Hi!

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

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


Thanks!
Jan 02 2017
parent reply crimaniak <crimaniak gmail.com> writes:
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?
Jan 04 2017
parent reply Geert <gerndz gmail.com> writes:
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);
Jan 05 2017
parent reply Daniel =?iso-8859-1?b?S2964Ws=?= via Digitalmars-d-learn writes:
Geert via Digitalmars-d-learn <digitalmars-d-learn puremagic.com>=20
napsal =C4=8Ct, led 5, 2017 v 3=E2=88=B613 :
 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!
=20
 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=20 have problems with database backup schema?
=20 Sorry for not being specific, my english it's not quite good. I=20 thought i could use a specific mysql-native method (like=20 "execProcedure") for making database backups, but it seems it doesn't=20 have it. =20 Anyway, i ended up using mysqldump with executeShell function: =20 string query =3D "mysqldump -uroot -ptest_pass test_db >=20 /home/user/mydb_backup.sql"; executeShell(query); =20 =20 For those who use lampp: =20 string query =3D "/opt/lampp/bin/mysqldump -uroot -ptest_pass test_db >=20 /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,=20 string dbName) { import std.process: spawnShell, wait; writefln("Host: %s, DB: %s", host, dbName); auto pid =3D spawnShell("mysqldump --max_allowed_packet=3D1024M -C -h "= =20 ~ host ~ " -P" ~ port ~ " -u" ~ credentials.user ~ " -p" ~=20 credentials.pwd ~ " -R --add-drop-database --skip-triggers=20 --ignore-table=3Dcars.history -B " ~ dbName ~ " |" ~ " mysql -u" ~ credentials.user ~ " -p" ~=20 credentials.pwd ~ " -h 127.0.0.1 -P" ~ portDst); wait(pid); } =
Jan 05 2017
parent Geert <gerndz gmail.com> writes:
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!
Jan 05 2017