One Star

mysql dump/export

Before each running of my job I wish to make a mysql backup to a file of the effected tables. Is this possible with one of the available components?
7 REPLIES
Community Manager

Re: mysql dump/export

Hello
You can use the tMysqlRow component which is used to execute sql statement.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: mysql dump/export

what about using mysqldump command to dump a number of tables?
we have over 20 tables that we want to transfer between database servers using a taldend job, and going table by table is going to be crazy.
One Star

Re: mysql dump/export

Hello
What you can do is sometihing like: mysqldump -u -p mydatabase table1 > table1.sql, you can do one command for each command you want.
One Star

Re: mysql dump/export

Hello
What you can do is sometihing like: mysqldump -u -p mydatabase table1 > table1.sql, you can do one command for each command you want.

which component should i use for that? tsystem?
One Star

Re: mysql dump/export

which component should i use for that? tsystem?

Correct, or SSH
Five Stars

Re: mysql dump/export

I had a mysqldump statement working fine in a tSSH component and I wanted to migrate it to a tsystem as the dump need to be done on the same machine (it saved my to manage login and password for the tSSH).
So I've been cut and past the code from tSSH to tSystem using Single Command. The code is (I've all my context variable set up properly)
"mysqldump -u " context.Login " -p" context.Password " --databases " context.dbname " > /home/" context.source "/Archive/" TalendDate.getDate("YYYYMMDD_hhmmss") "_" context.source ".sql"

Then in the standard output I've the following choices:
- to console: print the command on screen but doesn't run it (useful to check that variable are properly used but doesn't do the job)
- to global variable: data is passed on to an output variable linked to the tSystem component. Not really what I want to do
- to console and to global variable: same comment as previously
- normal: data is passed on to the component that comes next, so I plug a tFileDelimited after and it wrote the mysqldump statement instead of the proper dump
So I guess I am missing something, thanks for your help.

tSystem documentation page:
https://help.talend.com/search/all?query=tSystem&content-lang=en
Community Manager

Re: mysql dump/export

Hi magdmartin
Export the Error output to the console, it will print the error on the console if it has error when executing this SQL. From your command, I see the only place in question is the date pattern for the method TalendDate.getDate(), it should be:
TalendDate.getDate("yyyyMMdd_hhmmss") or TalendDate.getDate("yyyyMMdd_HHmmss")
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business