Place date on file generated by mysqldump

1
Hello, I want to put date in the file generated by mysqldump, I have a shell script that generates the dump, but I need to put the date that was generated in the file name

Ex:
// I have this command

mysqldump -uroot -p12345 base_diversos > base_diversos.sql

the file "base_diversos.sql" is generated without problems, I need the file to have date in the name: Ex:

mysqldump -uroot -p12345 base_diversos > base_diversos_25_02_2015.sql

How to put in the script the date variables to stay dynamic and generate with the current date being backed up?

would be something like: Ex:

mysqldump -uroot -p12345 base_diversos > base_diversos_%d_%m_%Y.sql

I've tried several ways and the error.

Thank you

    
asked by anonymous 07.04.2015 / 15:55

1 answer

1

By expanding the command date :

base_diversos_$(date +%d_%m_%Y).sql

In the man page of date ( man date ) has the list of possible formats.

    
07.04.2015 / 16:11