#!/bin/bash
# Created by Kahnu 06-09-23
# MySQL database details
DB_USER="root"
DB_PASSWORD="root@123"
DB_NAME="education"
# Timestamp for the backup file
TIMESTAMP=$(date +%Y-%m-%d-%H:%M:%S)
# Backup directory
BACKUP_DIR="dump/sql"
# Create a directory if it doesn't exist
mkdir -p $BACKUP_DIR
# Dump the database to a SQL file
mysqldump -u $DB_USER -p$DB_PASSWORD $DB_NAME > $BACKUP_DIR/$DB_NAME-$TIMESTAMP.sql
# Check if the dump was successful
if [ $? -eq 0 ]; then
echo "Database dump completed successfully"
else
echo "Error: Database dump failed"
fi
0 Comments
Post a Comment