Put date in file generated by mysqldump

Asked

Viewed 753 times

1

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

Ex:
//have this command

mysqldump -uroot -p12345 base_diversos > base_diversos.sql

is generated the file "base_diversos.sql 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 script the date variables to be 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 error.

Thank you

2 answers

2


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.

  • It worked right, tmb saw the documentation on the function tiha everything there but not as you described. Thanks for the help.

-1

mysqldump -hlocalhost -uroot -Proot test_111 > "C: Users USER_2 Desktop backup Folder test_111_%date:~-4.4%date:~-10.2%date:~-7.2%_%time:~0.2%time:~3.2%time:~6.2%. sql"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.