使用crontab+ssh每天自动完全备份mysql数据

2009-05-13 15:25:00来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折


自动ssh/scp方法配置
A为本地主机(即用于控制其他主机的机器) ;
B为远程主机(即被控制的机器Server), 假如ip为192.168.60.110;
A和B的系统都是Linux
在A上运行命令:
#cd ~
# ssh-keygen -t rsa (连续三次回车,即在本地生成了公钥和私钥,不设置密码)
#
[url=javascript:;]ssh[/url]
backup@192.168.60.110
“mkdir .ssh” (建立目录,需要输入密码,只需一次)
# scp ~/.ssh/id_rsa.pub backup
@192.168.60.110
:.ssh/id_rsa.pub (copy本地公钥到B,需要输入密码)
===============================================
08-07-03改动
当B机重装或改动时可能遇到下面状况
可能遇到的问题:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
be:5f:d2:45:66:4d:0c:9e:2b:6b:45:65:a7:b2:85:28.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:11
RSA host key for localhost has changed and you have requested strict checking.
Host key verification failed.
如上问题,请删除 ~/.ssh/known_hosts指定的行,如上面的第11行,然后再试。
=========================================================

在B上用backup用户的命令:
#cd ~
# touch .ssh/authorized_keys (如果已经存在这个
[url=javascript:;]文件[/url]
, 跳过这条)
# cat .ssh/id_rsa.pub >> .ssh/authorized_keys (将id_rsa.pub的内容追加到authorized_keys 中)
回到A机器:
# ssh backup
@192.168.60.110
(不需要密码, 登录成功)
在a机上建立放
[url=javascript:;]脚本[/url]
的目录
# cd /opt/lampp
# mkdir
[url=javascript:;]shell[/url]
copy文件到上面目录
# chmod +x mysqlbackup.sh
在本地/home/backup下建立本地
[url=javascript:;]备份[/url]
目录
# cd /home/backup
# mkdir mysqlbackup && chown
[url=javascript:;]root[/url]
:website mysqlbackup && chmod 0666 mysqlbackup
[url=javascript:;]crontab[/url]
设置,每天凌晨3点执行
# crontab -e
0 3 * * * /bin/sh /opt/lampp/shell/mysqlbackup.sh
发下为脚本mysqlbackup.sh
#!/bin/bash
#每天备份
[url=javascript:;]mysql[/url]

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:使用nginx负载均衡lucene

下一篇:Configuring IPSec VPN Connection Between FreeBSD a