I'm setting up a scrip to dump a Mysql server, the name of the generated file is like this (bckp_all_13-09-2018.tar.bz2), however I wanted to store the time too, so (bckp_all_13-09- 2018_14: 44: 22.tar.bz2).
Does anyone know how to do this?
Code sample:
#!/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