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
0 comments:
Post a Comment