BackupPC安装
下载地址
https://sourceforge.net/projects/backuppc/
网上有中文网址,但是都试yum安装,我自己写一篇如何使用源码编译安装,毕竟yum安装的版本不可控
系统环境搭建
1 添加用户
groupadd backuppc
useradd -G backuppc backuppc
2 安装
2.1 安装backuppc-xs
cd backuppc-xs-0.59
./configure.sh
perl Makefile.PL
make
make test
make install
2.1 安装rsync
下载地址 https://github.com/backuppc/rsync-bpc/releases,注意我使用3.1开头的版本无法安装成功,所以建议不要安装3.1开头的版本
tar -xvf rsync-bpc-3.0.9.14.tar.gz
cd rsync-bpc-3.0.9.14
./configure
make
make install
2.2 下载httpd,并安装依赖包
yum -y install openssl-devel pcre-devel expat-devel libtool perl-CPAN bzip2 par2 rrdtool rsync_bpc sendmail samba-client git build-essential perl-devel perl-CPAN perl-CGI gcc httpd mod_ssl glusterfs-client
perl -MCPAN -e shell
cpan
install version
install Digest::MD5
install File::Listing
install Archive::Zip
install XML::RSS
install CGI
install BackupPC::XS
install Net::FTP
install Net::FTP::RetrHandle
install Net::FTP::AutoReconnect
2.3 安装apr
tar -xvf apr-1.7.0.tar.gz
cd apr-1.7.0
vim configure
# $RM "$cfgfile" #注释掉这一行
./configure --prefix=/usr/local/apr
make && make install
2.3 安装apr
tar -xvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
2.4 安装httpd
tar -xvf httpd-2.4.41.tar.gz
cd httpd-2.4.41
./configure --prefix=/app/httpd24 \
--sysconfdir=/app/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork
make && make install
注意我的httpd安装在了/app/httpd24,这个可以根据需要自行修改
2.5 安装BackupPC
安装BackupPC
tar zxf BackupPC-4.3.0.tar.gz
cd BackupPC-4.3.0
perl configure.pl
perldoc configure.pl
根据安装包下的configure.pl中查看如下源码
my $ConfigDir = $opts{"config-dir"} || "/etc/BackupPC";
my $ConfigPath = "";
my $ConfigFileOK = 1;
while ( 1 ) {
if ( $ConfigFileOK && -f "$DestDir$ConfigDir/config.pl"
&& (!defined($opts{fhs}) || $opts{fhs}) && !defined($opts{"config-path"}) ) {
$ConfigPath = "$ConfigDir/config.pl";
$opts{fhs} = 1 if ( !defined($opts{fhs}) );
print <<EOF;
可以看出默认读取的是/etc/BackupPC下的config.pl文件,这个可以根据需要修改这部分配置信息,我就不修改了,按照默认的创建文件夹以及修改配置文件
mkdir -p /etc/BackupPC
安装文件夹下的conf目录下有config.pl的模板,下面根据模板进行修改
$Conf{ServerHost} = '192.168.23.65';
$Conf{XferMethod} = 'tar';#可选的有rsync,rsyncd,tar
$Conf{TopDir} = '/app/backupPC/TopDir';#存储所有备份数据的位置
$Conf{ConfDir} = '/app/backupPC/ConfDir';#主配置和hosts文件所在的位置
$Conf{LogDir} = '/app/backupPC/LogDir';#日志文件和其他临时信息所在的位置
$Conf{RunDir} = '/app/backupPC/RunDir';#pid和sock文件所在的位置
$Conf{InstallDir} = '/usr/share/BackupPC';#bin、lib和doc安装目录所在的位置。
$Conf{CgiDir} = '/usr/share/BackupPC/sbin';#BackupPC_Admin的Apache CGI目录
$Conf{CgiImageDir} = '/usr/share/BackupPC/'
$Conf{CgiAdminUserGroup} = 'backuppc';
$Conf{CgiAdminUsers} = 'backuppc';
$Conf{Language} = 'zh_CN'; #修改文件目录
修改完之后拷贝到/etc/BackupPC下,然后进入安装包所在目录
perl configure.pl
/app/httpd24/bin/htpasswd -c /etc/BackupPC/apache.users backuppc
chown -R backuppc:backuppc /usr/share/BackupPC/
chown -R backuppc:backuppc /app/backup
修改/app/BackupPC-4.3.0/systemd/src/backuppc.service,将相关参数进行替换然后拷贝到/etc/systemd/system
[Unit]
Description=BackupPC server
After=syslog.target local-fs.target
[Service]
Type=simple
User=backuppc
#Group=backuppc
ExecStart=/usr/share/BackupPC/bin/BackupPC
ExecReload=/bin/kill -HUP $MAINPID
RuntimeDirectory=BackupPC
PIDFile=/app/backupPC/RunDir/BackupPC.pid
KillSignal=SIGTERM
Restart=always
RestartSec=1
[Install]
WantedBy=multi-user.target
cp /app/BackupPC-4.3.0/systemd/src/backuppc.service /etc/systemd/system
chown -R backuppc:backuppc /app/BackupPC-4.3.0
systemctl start backuppc.service #启动
systemctl status backuppc.service #状态
systemctl stop backuppc.service #停止
没有问题应该可以启动,有问题再查日志吧
2.6 启动apache
编写BackupPC.conf配置文件
<VirtualHost *:80>
ServerName backuppc.local.Dev
DocumentRoot /usr/share/BackupPC
<Directory /usr/share/BackupPC/>
AuthType Basic
AuthUserFile /etc/BackupPC/apache.users
AuthName "BackupPC"
<IfModule mod_authz_core.c>
<RequireAll>
Require valid-user
<RequireAny>
Require valid-user
</RequireAny>
</RequireAll>
</IfModule>
<IfModule !mod_authz_core.c>
order deny,allow
allow from all
</IfModule>
</Directory>
Alias /BackupPC/images /usr/share/BackupPC/
ScriptAlias /BackupPC /usr/share/BackupPC/sbin/BackupPC_Admin
ScriptAlias /backuppc /usr/share/BackupPC/sbin/BackupPC_Admin
</VirtualHost>
修改http的配置文件httpd.conf以下几个部分,引用上面配置的
User backuppc
Group backuppc
ServerName 0.0.0.0
# Virtual hosts
#Include /extra/httpd-vhosts.conf
Include /app/httpd24/BackupPC.conf
TypesConfig /app/httpd24/mime.types
#添加
LoadModule cgi_module modules/mod_cgi.so