备案老域名

已经备案域名购买,老域名出售,已备案域名交易,老域名查询,已经备案域名注册,老域名抢注,Godaddy,宜春网站建设

« 上一篇下一篇 »

VPS定时自动备份终极指南

 

近半年,先后丢失5个网站数据,大多都是由于VPS硬盘损坏造成,RAID10为了速度是很不保险的。最近的2次分别是DirectSpace和BuyVM,所以,必需备份,作好VPS随时准备丢失数据的准备。

昨天花了一整天,把目前所有的站做了每日同步,以下分享给大家实际操作方法。网上关于rsync的资料也不少,但多数我想会把你看晕的,以下我用实例来讲解,重点的地方我会详细说明,希望让大家都会用。

以下,假设网站所在的VPS为A,存储备份的VPS为B,系统均为CentOS。

备份方法为 B 定时向 A 拉数据来备份

一、VPS A 上面的具体部署

1. 安装 rsync

yum -y install rsync

把rsync加入开机启动

echo 'rsync --daemon' >> /etc/rc.d/rc.local

2. 设置rsync密码

echo '你的用户名:你的密码' > /etc/rsyncd.scrt

chmod 600 /etc/rsyncd.scrt

这里的用户名和密码,在VPS B上将会用到

3. 配置rsync

vim /etc/rsyncd.conf

放入以下内容, #后面是我的注释

下载:rsyncd.conf

uid = root

gid = root

use chroot = no

read only = yes

max connections = 10

port = 873

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

#log file = /var/log/rsync.log # 偶不想记录log

log format = %t %a %m %f %b

syslog facility = local3

timeout = 300

[www]

path = /var/www/

comment = AAA.com

ignore errors

read only = yes

list = no

auth users = andy

secrets file = /etc/rsyncd.scrt

#exclude = AAA.com/blog/cache/ #不需要备份的目录,我使用exclude from方法来排除

exclude from = /etc/rsync_exclude.txt

hosts allow = 备份服务器的IP

hosts deny = *

4. 排除不备份的目录

vim /etc/rsync_exclude.txt

输入不备份的目录,每行一个,不可以用绝对路径,而必须用上面配置文件中path的相对路径,如

AAA.com/blog/cache/

AAA.com/manual/

这个排除文件有更高级的+-写法,我们不需要,简单够用就好,用 exclude from 方法,好处在于随时要添加不需要备份的内容时,方便添加,且不需要重启rsync进程

日历

控制面板

网站分类

最近发表

搜索

图标汇集

网站收藏

Tags列表

友情链接

Copyright www.hfyixinsoft.cn. Some Rights Reserved.