Page 1 of 1

Using Livecode to dump backup mySql database

Posted: Mon Aug 04, 2014 3:23 pm
by nicoloose
Hi all,

I would like my users to be able to backup data from my mySql database and store the backup in a specific location. The location is the easy part but I am wondering what the best way is to backup every table, each with it's own filename. I guess this would require iterating through all the tables in a database?

Thanks for the help.
N

Re: Using Livecode to dump backup mySql database

Posted: Tue Aug 05, 2014 2:05 am
by JackieBlue
I would think this would best be done through your MySQL administrator tools rather than writing a separate program. If you want to use LC I'm sure you could execute the same commands from LC to execute a backup.

Re: Using Livecode to dump backup mySql database

Posted: Tue Aug 05, 2014 7:57 am
by nicoloose
It seems a bit long winded so I thought that I could embed some PHP scripts to do the work for me.. I will look into it. Unfortunately, my users would not be able to use PhpMyadmin tools which is why I would need them to use LC. Click a button, choose a folder and press go and the script does the rest.

Re: Using Livecode to dump backup mySql database

Posted: Tue Aug 05, 2014 10:05 am
by bangkok
nicoloose wrote:It seems a bit long winded so I thought that I could embed some PHP scripts to do the work for me.. I will look into it. Unfortunately, my users would not be able to use PhpMyadmin tools which is why I would need them to use LC. Click a button, choose a folder and press go and the script does the rest.
Creating the backup directly on the server would allow you to use the very powerfull mysqldump command, with a solution mixing bash shell and PHP/Livecode Server.

-write a script in PHP (or LiveCode Server)
-this script would be called by your client (through basic URL www.test.com/dobackup.php)
-this script uses a bash shell script (with mysqldump) to create the backup on the fly
-the client can then download the backup (with regular Livecode : put url... into...)

Here is an example (for Postgresql)

Code: Select all

#!/bin/bash
echo "lets erase the previous backup"
set -e
rm '/home/xxx/backup/mydb.sql'
echo "lets dump the database"
sudo -u postgres pg_dump demo -C > /home/xxx/backup/mydb.sql
echo "END"
Other ideas :
-you could add a cron task (in order to create automatically the backup on the server)
-use some kind of encryption (for the backup file), some of identification (the client would have to identify himself before to be able to create the backup and/or download the file) etc.

Re: Using Livecode to dump backup mySql database

Posted: Fri Aug 08, 2014 10:25 am
by nicoloose
Many thanks for those two suggestions. I will be testing them both but I think a cron task is actually best. No user input is more reliable.

Re: Using Livecode to dump backup mySql database

Posted: Fri Aug 08, 2014 3:44 pm
by MaxV
Probably here you find all best MySQL backup strategies: http://dev.mysql.com/doc/refman/5.1/en/ ... thods.html