I set up the script below to perform backups of three Mysql databases. I wonder if it's correct.
#VARIAVEIS
DATE='date +%Y%m%d-%H%M'
HOSTNAME1="xxxxx"
HOSTNAME2="yyyyy"
HOSTNAME3="zzzzz"
USER='xyzedmar'
PASSWORD='xyz2'
DATABASE1='xxxxx'
DATABASE2='yyyyy'
DATABASE3='zzzzz'
DIR='http://site/mysql-bkp/'
#backup do banco de dados
mysqldump --host=$HOSTNAME1 --user=$USER --password=$PASSWORD --databases $DATABASE1 > $DIR/backup_$DATABASE1_$DATE.sql
mysqldump --host=$HOSTNAME2 --user=$USER --password=$PASSWORD --databases $DATABASE2 > $DIR/backup_$DATABASE2_$DATE.sql
mysqldump --host=$HOSTNAME3 --user=$USER --password=$PASSWORD --databases $DATABASE3 > $DIR/backup_$DATABASE3_$DATE.sql
But I need help for
1) How do I delete the files from the previous days, after the updated backups have been made?
2) What is the Cron code for running the script?