How to take MySQL backup and restore remotely

Create a shell script for MySQL backup remotely

use -h for remote host address

#!/bin/bash

username="username"

dbname="dbname"

dbhost="dbhostname"

password="password"

today=$(date +"%Y-%m-%d_%H-%M")

mkdir -p /home/username/dbBackup

#echo "MySQL Backup Started"

mysqldump -u $username -p'$password' -h $dbhost  $dbname > /home/username/dbBackup/$today.sql

echo "Mysql Back up completed"


How to restore MySQL backup remotely

mysql -u username  -p -h dbhostname/ipaddress  dbname < backup.sql


Share on Google Plus

About Md. Shahzad Alam

I am a passionate cloud and DevOps professional specializing in Linux and open-source solutions. Through this blog, I share my knowledge and experience with the community, offering tips and insights on cloud technologies and DevOps practices.
    Blogger Comment

0 comments:

Post a Comment