Using Livecode to dump backup mySql database

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
nicoloose
Posts: 99
Joined: Mon Sep 16, 2013 3:35 pm

Using Livecode to dump backup mySql database

Post by nicoloose » Mon Aug 04, 2014 3:23 pm

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

JackieBlue
Posts: 32
Joined: Sun Jun 22, 2014 2:37 am

Re: Using Livecode to dump backup mySql database

Post by JackieBlue » Tue Aug 05, 2014 2:05 am

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.

nicoloose
Posts: 99
Joined: Mon Sep 16, 2013 3:35 pm

Re: Using Livecode to dump backup mySql database

Post by nicoloose » Tue Aug 05, 2014 7:57 am

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.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Using Livecode to dump backup mySql database

Post by bangkok » Tue Aug 05, 2014 10:05 am

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.

nicoloose
Posts: 99
Joined: Mon Sep 16, 2013 3:35 pm

Re: Using Livecode to dump backup mySql database

Post by nicoloose » Fri Aug 08, 2014 10:25 am

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.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Using Livecode to dump backup mySql database

Post by MaxV » Fri Aug 08, 2014 3:44 pm

Probably here you find all best MySQL backup strategies: http://dev.mysql.com/doc/refman/5.1/en/ ... thods.html
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply