3
I am mounting a scrip to dump a Mysql server, the name of the generated file is like this (bckp_all_13-09-2018.tar.bz2), but I wanted to store the time too, so (bckp_all_13-09-2018_14:44:22.tar.bz2).
Someone knows how to do it?
Example of the Code:
#!/bin/bash
MY_USER="root"
MY_PASSWORD="123456"
MY_HOME="/home/hugo"
case $1 in
"backupall")
cd $MY_HOME/Backup
mysqldump --opt --password=$MY_PASSWORD --user=$MY_USER --all-databases > bckp_all_$(date +'%d-%m-%Y').sql
tar -cvjf bckp_all_$(date +'%d-%m-%Y').tar.bz2 bckp_all_$(date +'%d-%m-%Y').sql
rm bckp_all_$(date +'%d-%m-%Y').sql;;
*) echo "Others";;
esac
'%d-%m-%Y'
sets the output format, then just add the parameters of hours, minutes and seconds.– Woss