0
I’m using a script to back up my database that I have in Mysql, I’m wondering how to put the date and time backup instead of just the date:
He gets like this:
alex_banco-2019-05-28.sql
But I wanted it to stay that way:
alex_banco-2019-05-28:13:18:51.sql
It would be possible to make that kind of change?
Definindo parametros do MySQL
echo " -- Definindo parametros do MySQL ..."
DB_NAME='atrizes'
DB_USER='alex'
DB_PASS='123456'
DB_PARAM='--add-drop-table --add-locks --extended-insert --single-transaction -quick'
# Definindo parametros do sistema
echo " -- Definindo parametros do sistema ..."
DATE=`date +%Y-%m-%d`
MYSQLDUMP=/usr/bin/mysqldump
BACKUP_DIR=/home/alex/backup
BACKUP_NAME=alex_banco-$DATE.sql
BACKUP_TAR=ales_banco-$DATE.tar
#Gerando arquivo sql
echo " -- Gerando Backup da base de dados $DB_NAME em $BACKUP_DIR/$BACKUP_NAME ..."
$MYSQLDUMP $DB_NAME $DB_PARAM -u $DB_USER -p$DB_PASS > $BACKUP_DIR/$BACKUP_NAME
# Compactando arquivo em tar
echo " -- Compactando arquivo em tar ..."
tar tar -cjf $BACKUP_DIR/$BACKUP_TAR -C $BACKUP_DIR $BACKUP_NAME --remove-files
# Excluindo backups antigos
echo " -- Excluindo backups com mais de 30 dias ..."
find $BACKUP_DIR/* -mtime +30 -delete
This is not a question concerning Mysql but the shell.
– anonimo