Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to properly inster the date into the mysqldump command

I’m trying to insert the date into the .sql file name when making a backup.

#!/bin/bash
sudo mysqldump --databases data > data-backup-$(date "+%D--%T").sql

But I get this error as output

./backup.sh: line 2: data-backup-$(date "+%D--%T").sql: No such file or directory

But when I exec the same command but without the date inserted there is no such error.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

date "+%D--%T" outputs something like 12/18/21--00:19:21.

/ is not allowed in file names with Linux/Unix.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading