0%

20240111开源备份backupPC

3.x版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
yum install BackupPC

cd /usr/share/BackupPC/
chown backuppc:apache sbin/*
cd sbin

chmod u+s BackupPC_Admin

usermod -s /bin/bash backuppc

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

# /etc/BackupPC/config.pl
$Conf{CgiAdminUsers} = 'backuppc';
$Conf{PingPath} = '/bin/ping';


htpasswd -c /etc/BackupPC/apache.users backuppc

zaq1XSW2

systemctl restart backuppc
systemctl restart httpd

4.x

1
2
3
4
5
6
yum --enablerepo=extras -y install epel-release
yum --enablerepo=epel-testing -y install BackupPC-XS rsync-bpc

yum groupinstall "Development Tools"


安装BackupPC-XS

1
2
3
4
5
6
7
8
 https://objects.githubusercontent.com/github-production-release-asset-2e65be/ 
tar zxf BackupPC-XS-0.62.tar.gz
cd BackupPC-XS-0.62

perl Makefile.PL
make
make test
make install

Install the following requisites for BackupPC version 4.3.1

1
2
3
4
5

yum -y install bzip2 httpd mod_perl par2cmdline perl-Archive-Zip perl-CGI \
perl-Compress-Raw-Zlib perl-Data-Dumper perl-Digest-MD5 perl-File-Listing \
perl-File-RsyncP perl-Net-FTP-AutoReconnect perl-Net-FTP-RetrHandle \
perl-Time-ParseDate perl-XML-RSS perl-version rrdtool samba-client

Lets set up some directories that we are going to use later.

My backuppc server has a raid10 array mounted at /data/. I am going to use this to store the data for backuppc. Lets create the backuppc folder on my raid. Note: this folder can grow to be extremely large.

1
mkdir -p /data/backuppc

Now lets create one more folder for BackupPC to store some web interface files.

1
mkdir -p /var/www/html/backuppc

And create the cgi-bin directory for backuppc

1
mkdir -p /var/www/cgi-bin/backuppc

Make note of those 2 directories. The installer will ask for them if we don’t explicitly set them below.

Create and setup the backuppc user.

Create group backuppc.

1
groupadd backuppc

Create backuppc user, and tell it where its home folder is. My backuppc user’s home folder is /opt/backuppc. Change this to whatever you’d like.

1
2
3
useradd --home-dir /opt/backuppc --create-home --shell /bin/bash --base-dir /opt/backuppc --gid backuppc backuppc


Set Permissions on the directories we created:

1
2
chown -R backuppc:backuppc /data/backuppc
chown -R backuppc:backuppc /opt/backuppc

Download the BackupPC tar.gz archive and extract it.

1
2
3
4
5
cd ~
wget https://github.com/backuppc/backuppc/releases/download/4.4.0/BackupPC-4.4.0.tar.gz
tar zxf BackupPC-4.4.0.tar.gz
cd BackupPC-4.4.0

Run the configure.pl script

Pay close attention to the paths in this command.

1
2
3
perl configure.pl --batch --cgi-dir /var/www/cgi-bin/backuppc \
--data-dir /data0/backuppc --hostname backuppc --html-dir /var/www/html/backuppc \
--html-dir-url /backuppc --install-dir /opt/backuppc

Alternatively, you can execute the perl script with no arguments and it will walk you through the install step by step. This is the preferred method if you are upgrading a version 3.X install. (Not supported by this guide)

1
perl configure.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Ok, we're about to:

- install the binaries, lib and docs in /usr/local/BackupPC
- create the data directory /data/BackupPC
- optionally install the cgi-bin interface
- create/update the config.pl file /etc/BackupPC/config.pl
--> Do you want to continue? [y]?
Created /usr/local/BackupPC/bin
Created /usr/local/BackupPC/share
Created /usr/local/BackupPC/share/doc
Created /usr/local/BackupPC/share/doc/BackupPC
Created /usr/local/BackupPC/lib
Created /usr/local/BackupPC/lib/BackupPC
Created /usr/local/BackupPC/lib/BackupPC/CGI
Created /usr/local/BackupPC/lib/BackupPC/Config
Created /usr/local/BackupPC/lib/BackupPC/Lang
Created /usr/local/BackupPC/lib/BackupPC/Storage
Created /usr/local/BackupPC/lib/BackupPC/Xfer
Created /usr/local/BackupPC/lib/BackupPC/Zip
Created /usr/local/BackupPC/lib/Net
Created /usr/local/BackupPC/lib/Net/FTP
Created /data/BackupPC
Created /data/BackupPC/pool
Created /data/BackupPC/cpool
Created /data/BackupPC/pc
Created /etc/BackupPC
Created /var/log/BackupPC
Created /var/run/BackupPC
Installing binaries in /usr/local/BackupPC/bin
Installing library in /usr/local/BackupPC/lib
Making systemd and init.d scripts
Making Apache configuration file for suid-perl
Installing docs in /usr/local/BackupPC/share/doc/BackupPC
Installing cgi script BackupPC_Admin in /var/www/cgi-bin/backuppc
Installing config.pl and hosts in /etc/BackupPC

Ok, it looks like we are finished. There are several more things you
will need to do:

- Browse through the config file, /etc/BackupPC/config.pl,
and make sure all the settings are correct. In particular,
you will need to set $Conf{CgiAdminUsers} so you have
administration privileges in the CGI interface.

- Edit the list of hosts to backup in /etc/BackupPC/hosts.

- Read the documentation in /usr/local/BackupPC/doc/BackupPC.html.
Please pay special attention to the security section.

- Verify that the CGI script BackupPC_Admin runs correctly. You might
need to change the permissions or group ownership of BackupPC_Admin.
If this is an upgrade and you are using mod_perl, you will need
to restart Apache. Otherwise it will have stale code.

- BackupPC should be ready to start. Don't forget to run it
as user backuppc! The installation also contains
a systemd/backuppc.service script that can be installed so
that BackupPC can auto-start on boot. This will also enable
administrative users to start the server from the CGI interface.
See systemd/README.

Enjoy!

Apache config

I chose the CGI route (not S-CGI) and chose the directory /var/www/cgi-bin/backuppc for my CGI directory. I chose /var/www/html/backuppc as my images directory. You may need to set this path in the config if you ran the configure.pl script with no arguments.

Now we need to copy the Apache config into the apache conf.d directory.

1
cp httpd/BackupPC.conf /etc/httpd/conf.d/

Install the included systemd script:

1
2
3
4
cp systemd/backuppc.service /etc/systemd/system/
systemctl daemon-reload
systemctl start backuppc
systemctl enable backuppc

Create the backuppc authentication file.

1
2
3
htpasswd -c /etc/BackupPC/BackupPC.users backuppc


Note: this sets the username to backuppc (modify it to your liking)

Set permissions on this file.

1
chown backuppc:backuppc /etc/BackupPC/BackupPC.users

Edit the config.pl file in /etc/BackupPC/

1
vim /etc/BackupPC/config.pl

Check the image directory and image url variables.

1
2
$Conf{CgiImageDir} = '/var/www/html/backuppc';
$Conf{CgiImageDirURL} = '/BackupPc';

Also add backuppc as the administrative user: $Conf{CgiAdminUsers} = 'backuppc';

这时候不能往/etc/BackupPC目录写东西,

chcon -R -t httpd_sys_content_t /etc/BackupPC

查看备份内容

1
2
3
4
5
6
# 列表
BackupPC_ls -h bi-server -n 0 -s /data/bakdata /
BackupPC_ls -h erp-oracle -n 1 -s /backup/bakdata /

#查看文件
BackupPC_zcat -h erp-oracle -n 1 -s /backup/bakdata /navy_bak221220_full.log