环境:Centos7.6、Backuppc
安装:(host:192.168.3.11)
[root@localhost ~]# yum install backuppc -y
配置:
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf (修改apache启动用户为backuppc)
User backuppc
Group backuppc
[root@localhost ~]# vim /etc/httpd/conf.d/BackupPC.conf(修改所有主机均可访问backuppc控制页面)
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAll>
Require valid-user
<RequireAny>
Require all granted
</RequireAny>
</RequireAll>
</IfModule>
由以上配置文件可知apache user文件为如下:
AuthUserFile /etc/BackupPC/apache.users
[root@localhost ~]# htpasswd -c /etc/BackupPC/apache.users backuppc
(这里密码设置为12345)
[root@localhost ~]# vim /etc/BackupPC/config.pl(配置backupc主配置文件)
$Conf{CgiAdminUsers} = 'backuppc';(配置backuppc账号为bckuppc)
$Conf{ServerInitdPath} = '/etc/init.d/backppc';(启动命令)
$Conf{ServerInitdStartCmd} = '$sshPath -q -x -l root $serverHost$serverInitdPath start';
$Conf{PingPath} = '/bin/ping';
$Conf{Language} = 'zh_CN';(更改web页面为中文)
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart backuppc
web测试:
web端添加需备份server:
点击“增删客户机”后,选择“客户机”,在右侧窗口“添加”指定server IP,这里测试用192.168.3.12,账号为backuppc,然后点“保存”
保存后刷新页面,选择刚添加server,选择“修改服务器设置”开始对其设置备份规则:
在“RsyncShareName”一栏输入需备份路径,这里设置为/test;然后再BackupFilesOnly一栏输入“*”,表示备份/test目录下所有文件,当然也可指定文件,然后点击保存:
SSH免密登陆设置:
[root@localhost ~]# cd /var/lib/BackupPC/
[root@localhost BackupPC]# mkdir .ssh
[root@localhost BackupPC]# chown backuppc.backuppc .ssh
[root@localhost BackupPC]# chmod 700 .ssh
[root@localhost BackupPC]# chmod 700 .ssh
[root@localhost BackupPC]# su -s /bin/bash backuppc
bash-4.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/BackupPC/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/BackupPC/.ssh/id_rsa.
Your public key has been saved in /var/lib/BackupPC/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:1dWLzmcZ22P8oz4oXHvCd145490rY0JVUoCuoR8vp6A backuppc@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
| ..+o |
| o o ..|
| o . + .|
| o . o o |
| S o + . =|
| . o o o Oo|
| .o * o +++|
| . .= O B.oB|
| E .= BoB+=|
+----[SHA256]-----+
bash-4.2$ ssh-copy-id root@192.168.3.12
对目标server操作:
[root@localhost ~]# mkdir /test
[root@localhost ~]# useradd backuppc
[root@localhost ~]# passwd backuppc
[root@localhost ~]# chown -R backuppc.backuppc /test
测试:
[root@localhost ~]# cp -r /boot/ /test
点击“192.168.3.12主页”,然后点击“开始完全备份”,即可开始完全备份:
点击“浏览备份”,即可查看所备份文件&目录,这里可以选择部分恢复或者全部恢复: