MySQL Backup Script
#!/bin/bash export PATH=/bin:/usr/bin:/usr/local/bin TIMESTAMP=`date +”%Y%d%m-%H%M”` DB_BACKUP_PATH=’/backup/dbbackup’ MYSQL_HOST=’localhost’ MYSQL_PORT=’3306′ MYSQL_USER=’root’ MYSQL_PASSWORD=’mysecret’ DATABASE_NAME=’mydb’ echo “Backup started for database – ${DATABASE_NAME}” mysqldump -h ${MYSQL_HOST} \ -P ${MYSQL_PORT} \ -u ${MYSQL_USER} \ -p${MYSQL_PASSWORD} \ ${DATABASE_NAME} | gzip –best > ${DB_BACKUP_PATH}/${DATABASE_NAME}-${TIMESTAMP}.sql.gz if [ $? -eq 0 ]; then echo “Database backup successfully completed” else echo “Error found during backup” exit … Read more