I need to backup a range of databases each day and I would like to do this via command line.
I’m using mysqldump to dump the db into a folder on the root of the server appended with the date. I would like to add the name of the database dynamically to the exported filename, rather than hard coding it into the query. Currently I have:
[~]# mysqldump -u user -h localhost -p unique_database_name > unique_database_name_1_$(date +%d%m%y).sql
The goal is to have ‘unique_database_name’ appended to the filename, so the script is a little more portable.
This script would do it: