How to generate a dynamic file name for a mysqldump on Linux? I want to schedule my MySql backs to happen on an hourly basis, but the problem is I want to customize the name of the file that is outputs but not to sure how to?

This is the command I am using now

mysqldump -u yourusername -h yourusername.mysql.pythonanywhere-services.com 'yourusername$dbname'  &gt; db-backup.sql


This works but I would to have it output a file something like this, but for it to happen dynamically, when the command is run

1-01-18.13:50.db-backup.sql


How could I do this on a single line of code
This should do it :

mysqldump -u yourusername -h yourusername.mysql.pythonanywhere-services.com 'yourusername$dbname'  &gt; `date +"\%Y-\%m-\%d_\%H-\%M"`.db-backup.sql


Will generate files like : 2018-01-01_13-50.db-backup.sql. You can adapt this to whatever exact format you want (but you should avoid using special characters such as :).

If you want to compress the file on the fly :

mysqldump -u yourusername -h yourusername.mysql.pythonanywhere-services.com 'yourusername$dbname'  | gzip &gt; `date +"\%Y-\%m-\%d_\%H-\%M"`.db-backup.sql.gz