automatic backup mysql database using SSH command line sqldump
mysqldump is a very usefull command and can be excuted as a normal users on the server.
4 most important parameter:
-u specify username
-p use a password, place password in () if need run it automatic.
-h specify the database server dns name, omit it if db is running localhost
> and < output(backup) and input(restore), specify the file path may necessary.
for example, when you need backup a database named mydb with a database user myusr on a server mysql.myhost.com.
run the backup command:
mysqldump -u mysur -p mydb -h mysql.myhost.com >mydb_backup
restore:
mysqldump -u mysur -p mydb -h mysql.myhost.com <mydb_backup
for automatic backup at a specific time. add an cron item. for example.
crontab -e
* * * * * mysqldump -u mysur -p (mypasswd) mydb -h mysql.myhost.com >mydb_backup$date.bak