{"id":5891,"date":"2020-05-17T23:36:22","date_gmt":"2020-05-17T20:36:22","guid":{"rendered":"https:\/\/kifarunix.com\/?p=5891"},"modified":"2024-03-14T20:32:42","modified_gmt":"2024-03-14T17:32:42","slug":"install-and-setup-backuppc-server-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-setup-backuppc-server-on-ubuntu-20-04\/","title":{"rendered":"Install and Setup BackupPC Server on Ubuntu 20.04"},"content":{"rendered":"\n
In this guide, we are going to learn how to install and setup BackupPC Server on Ubuntu 20.04. BackupPC<\/a>\u00a0is a high-performance enterprise-grade cross-platform backup software suite with a web-based frontend. It can be used for backing up Linux, Windows and Mac OSXs PCs and laptops to a server\u2019s disk. <\/p>\n\n\n\n BackupPC provides quite a number of features;<\/p>\n\n\n\n Read more on About BackupPC<\/a> page.<\/p>\n\n\n\n To begin with, ensure that your system packages are up-to-date.<\/p>\n\n\n\n As of this writing, BackupPC 4.3.2 is the latest stable release version. Unfortunately, the default Ubuntu 20.04 repos provides BackupPC 3.3.2;<\/p>\n\n\n\n As such, we are going to build BackupPC 4 on Ubuntu 20.04 from source.<\/p>\n\n\n\n BackupPC is usually run by a low privileged BackupPC V4+ requires BackupPC XS, a perl module that implements various BackupPC functions in a perl-callable module.<\/p>\n\n\n\n Download BackupPC XS source code;<\/p>\n\n\n\n Build and install BackupPC XS;<\/p>\n\n\n\n To install this module, run the following commands:<\/p>\n\n\n\n Run the If everything is in order, the result should be pass;<\/p>\n\n\n\n Install BackupPC XS module;<\/p>\n\n\n\n There are other optional but highly RECOMMENDED modules that have been installed on the requirements section above.<\/p>\n\n\n\n In order to be able to backup clients using Download rsync_bpc source code;<\/p>\n\n\n\n Compile and install the rsync_bpc module;<\/p>\n\n\n\n This configures rsync_bpc with the default options. You can check other configuration options with the command, Compile and install rsync_bpc;<\/p>\n\n\n\n Once all the above is done, you can now install BackupPC itself. Download the source code cloning the Github repository;<\/p>\n\n\n\n Navigate to backup source directory;<\/p>\n\n\n\n Generate the latest release BackupPC tarball from the source file and BackupPC build tools;<\/p>\n\n\n\n This creates BackupPC tarball and store it under distr directory in the current working directory as, for example, dist\/BackupPC-4.3.2.tar.gz<\/strong>, for the current stable release (as of this writing).<\/p>\n\n\n\n Extract the source code;<\/p>\n\n\n\n Build and install BackupPC server;<\/p>\n\n\n\n The script when executed in this way, will run interactively. Answer the prompts accordingly. Press ENTER<\/strong> to accept the defaults.<\/p>\n\n\n\n If you want to run non-interactive installation;<\/p>\n\n\n\n Copy the sample BackupPC Apache configuration file to Apache enabled configurations directory;<\/p>\n\n\n\n Next, configure Apache to allow external access to BackupPC;<\/p>\n\n\n\n Configure Apache to run as BackupPC user, Remove the set-uid from BackupPC admin CGI file;<\/p>\n\n\n\n Change the Basic authentication file if you so wish;<\/p>\n\n\n\n Change the basic authentication message;<\/p>\n\n\n\n Create the BackupPC basic authentication user and password. This information should be stored on a file specified by the value of the You can add another user, say Adjust the ownership and permissions of the auth user file;<\/p>\n\n\n\n Default Administrative user for BackupPC is defined under CGI user interface configuration settings section. Normal users can only access information specific to their host. They can also start\/stop\/browse\/restore backups. Administrative users have full access to all hosts, plus overall status and log information. In this demo, we set the By default, BackupPC uses the root user on the backup clients for backup purposes.<\/p>\n\n\n\n It is more secure to allow backup via a low-privileged user. In this demo, we will create a non-privileged user, We will leave other Rsync settings with the default options.\\<\/p>\n\n\n\n Note that all these configurations are overwritable via the per-client configuration.<\/strong><\/p>\n\n\n\n Run the commands below to enable BackupPC Apache configuration and CGI modules;<\/p>\n\n\n\n Disable Apache default site and Disable directory listing;<\/p>\n\n\n\n Hide web server version on error pages;<\/p>\n\n\n\n Check Apache for any errors;<\/p>\n\n\n\n Start and enable Apache to run on system boot;<\/p>\n\n\n\n Restart Apache if it were already running;<\/p>\n\n\n\n Copy BackupPC sample systemd service file from the source directory;<\/p>\n\n\n\n Edit the service group;<\/p>\n\n\n\n Reload systemd service configuration;<\/p>\n\n\n\n Start and enable BackupPC service;<\/p>\n\n\n\n To check the status;<\/p>\n\n\n\n If firewall is running, allow external access to Apache.<\/p>\n\n\n\n You can now access BackupPC via the URL Authenticate and proceed to BackupPC web dashboard.<\/p>\n\n\n\n When you authenticate as admin user, this is the interface you get;<\/p>\n\n\n\n When you authenticate as non admin user, this is the interface you get;<\/p>\n\n\n\n BackupPC is now installed on Ubuntu 20.04. You can now go ahead and add hosts for backing up;<\/p>\n\n\n\n Backup Linux systems with BackupPC using Rsync Protocol<\/a><\/p>\n\n\n\n Backup Windows System via SMB Using BackupPC<\/a><\/p>\n\n\n\n Backup Windows System with BackupPC Using Rsyncd<\/a><\/p>\n\n\n\n Installing BackupPC 4 from tarball or git on Ubuntu<\/a><\/p>\n\n\n\n BackupPC Documentation: Installing BackupPC<\/a><\/p>\n\n\n\n Install and Configure BackupPC on Debian 10<\/a><\/p>\n\n\n\n How to Install and Configure BackupPC as a Backup Server on Ubuntu 18.04<\/a><\/p>\n\n\n\n\n
Installing BackupPC Server on Ubuntu 20.04<\/h2>\n\n\n\n
Update System packages<\/h3>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
apt upgrade<\/code><\/pre>\n\n\n\n
Install BackupPC<\/h3>\n\n\n\n
apt show backuppc<\/code><\/pre>\n\n\n\n
Package: backuppc\nVersion: 3.3.2-3\nPriority: optional\nSection: utils\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>\nOriginal-Maintainer: Debian BackupPC Team <team+pkg-backuppc@tracker.debian.org>\nBugs: https:\/\/bugs.launchpad.net\/ubuntu\/+filebug\nInstalled-Size: 2,314 kB\n...\nHomepage: https:\/\/backuppc.github.io\/backuppc\/\nDownload-Size: 460 kB\nAPT-Sources: http:\/\/ke.archive.ubuntu.com\/ubuntu focal\/main amd64 Packages<\/code><\/pre>\n\n\n\n
Install Required Dependencies<\/h4>\n\n\n\n
apt install apache2 apache2-utils libapache2-mod-perl2 par2 perl smbclient rsync tar gcc zlib1g zlib1g-dev rrdtool git make perl-doc libnss-winbind winbind libarchive-zip-perl libfile-listing-perl libxml-rss-perl libcgi-session-perl libacl1-dev curl -y<\/code><\/pre>\n\n\n\n
Create BackupPC User<\/h4>\n\n\n\n
backuppc<\/strong><\/code> user with
\/var\/lib\/backuppc<\/strong><\/code> as the working directory. As such, create a backuppc system user by executing the command below;<\/p>\n\n\n\n
useradd -r -m -d \/var\/lib\/backuppc -s \/bin\/bash -c \"BackupPC user\" backuppc<\/code><\/pre>\n\n\n\n
Build and Install BackupPC XS<\/h4>\n\n\n\n
git clone https:\/\/github.com\/backuppc\/backuppc-xs.git<\/code><\/pre>\n\n\n\n
cd backuppc-xs\/<\/code><\/pre>\n\n\n\n
perl Makefile.PL<\/code><\/pre>\n\n\n\n
make<\/code><\/pre>\n\n\n\n
make test<\/code> to verify the correctness of the compilation of the module;<\/p>\n\n\n\n
make test<\/code><\/pre>\n\n\n\n
t\/BackupPC_XS.t .. ok\nAll tests successful.<\/strong>\nFiles=1, Tests=1, 0 wallclock secs ( 0.00 usr 0.04 sys + 0.07 cusr 0.03 csys = 0.14 CPU)\nResult: PASS<\/strong><\/code><\/pre>\n\n\n\n
make install<\/code><\/pre>\n\n\n\n
Install BackupPC rsync_bpc<\/h4>\n\n\n\n
rsync<\/code> command, you need
rsync_bpc<\/code> module installed. Rsync-bpc is a customized version of rsync that is used as part of BackupPC.<\/p>\n\n\n\n
cd ~<\/code><\/pre>\n\n\n\n
git clone https:\/\/github.com\/backuppc\/rsync-bpc.git<\/code><\/pre>\n\n\n\n
cd rsync-bpc<\/code><\/pre>\n\n\n\n
.\/configure<\/code><\/pre>\n\n\n\n
.\/configure --help<\/code>.<\/p>\n\n\n\n
make<\/code><\/pre>\n\n\n\n
make install<\/code><\/pre>\n\n\n\n
Install BackupPC on Ubuntu 20.04<\/h4>\n\n\n\n
cd ~<\/code><\/pre>\n\n\n\n
git clone https:\/\/github.com\/backuppc\/backuppc.git<\/code><\/pre>\n\n\n\n
cd backuppc<\/code><\/pre>\n\n\n\n
VER=`curl --silent \"https:\/\/api.github.com\/repos\/backuppc\/backuppc\/releases\/latest\" | grep '\"tag_name\":' | sed -E 's\/.*\"([^\"]+)\".*\/\\1\/'`<\/code><\/pre>\n\n\n\n
.\/makeDist --nosyntaxCheck --releasedate 'date -u \"+%d %b %Y\"' --version $VER<\/code><\/pre>\n\n\n\n
tar zxf dist\/BackupPC-*.tar.gz<\/code><\/pre>\n\n\n\n
cd BackupPC-*<\/code><\/pre>\n\n\n\n
perl configure.pl<\/code><\/pre>\n\n\n\n
Is this a new installation or upgrade for BackupPC? If this is\nan upgrade please tell me the full path of the existing BackupPC\nconfiguration file (eg: \/etc\/BackupPC\/config.pl). Otherwise, just\nhit return.\n\n--> Full path to existing main config.pl []? \n\nI found the following locations for these programs:\n\n bzip2 => \/usr\/bin\/bzip2\n cat => \/usr\/bin\/cat\n df => \/usr\/bin\/df\n gtar\/tar => \/usr\/bin\/tar\n gzip => \/usr\/bin\/gzip\n hostname => \/usr\/bin\/hostname\n nmblookup => \/usr\/bin\/nmblookup\n par2 => \/usr\/bin\/par2\n perl => \/usr\/bin\/perl\n ping => \/usr\/bin\/ping\n ping6 => \/usr\/bin\/ping6\n rrdtool => \/usr\/bin\/rrdtool\n rsync => \/usr\/bin\/rsync\n rsync_bpc => \/usr\/local\/bin\/rsync_bpc\n sendmail => \n smbclient => \/usr\/bin\/smbclient\n split => \/usr\/bin\/split\n ssh\/ssh2 => \/usr\/bin\/ssh\n\n--> Are these paths correct? [y]? y\n\nPlease tell me the hostname of the machine that BackupPC will run on.\n\n--> BackupPC will run on host [ubuntu20]? \n\nBackupPC should run as a dedicated user with limited privileges. You\nneed to create a user. This user will need read\/write permission on\nthe main data directory and read\/execute permission on the install\ndirectory (these directories will be setup shortly).\n\nThe primary group for this user should also be chosen carefully.\nThe data directories and files will have group read permission,\nso group members can access backup files.\n\n--> BackupPC should run as user [backuppc]?\n\nPlease specify an install directory for BackupPC. This is where the\nBackupPC scripts, library and documentation will be installed.\n\n--> Install directory (full path) [\/usr\/local\/BackupPC]? \n\nPlease specify a data directory for BackupPC. This is where all the\nPC backup data is stored. This file system needs to be big enough to\naccommodate all the PCs you expect to backup (eg: at least several GB\nper machine).\n\n--> Data directory (full path) [\/data\/BackupPC]? \/var\/lib\/backuppc\n\nBackupPC has SCGI and CGI perl interfaces that run under Apache. You need\nto pick which one to run.\n\n...\nThe traditional alternative is to use CGI. In this case, an executable needs\nto be installed Apache's cgi-bin directory. This executable needs to run as\nset-uid backuppc, or it can be run under mod_perl with Apache\nrunning as user backuppc.\n\n--> SCGI port (-1 to disable) [-1]? \n--> CGI bin directory (full path, or empty for no CGI) []? \/var\/www\/cgi-bin\/BackupPC\n\nBackupPC's CGI and SCGI script need to display various PNG\/GIF\nimages that should be stored where Apache can serve them. They\nshould be placed somewhere under Apache's DocumentRoot. BackupPC\nalso needs to know the URL to access these images. Example:\n\n Apache image directory: \/var\/www\/htdocs\/BackupPC\n URL for image directory: \/BackupPC\n\nThe URL for the image directory should start with a slash.\n\n--> Apache image directory (full path, or empty for no S\/CGI) []? \/var\/www\/html\/BackupPC\n--> URL for image directory (omit http:\/\/host; starts with '\/', or empty for no S\/CGI) []? \/BackupPC\n\nOk, we're about to:\n\n - install the binaries, lib and docs in \/usr\/local\/BackupPC\n - create the data directory \/var\/lib\/backuppc\n - optionally install the cgi-bin interface\n - create\/update the config.pl file \/etc\/BackupPC\/config.pl\n\n--> Do you want to continue? [y]?y\n...\nOk, it looks like we are finished. There are several more things you\nwill need to do:\n\n - Browse through the config file, \/etc\/BackupPC\/config.pl,\n and make sure all the settings are correct. In particular,\n you will need to set $Conf{CgiAdminUsers} so you have\n administration privileges in the CGI interface.\n\n - Edit the list of hosts to backup in \/etc\/BackupPC\/hosts.\n\n - Read the documentation in \/usr\/local\/BackupPC\/doc\/BackupPC.html.\n Please pay special attention to the security section.\n\n - Verify that the CGI script BackupPC_Admin runs correctly. You might\n need to change the permissions or group ownership of BackupPC_Admin.\n If this is an upgrade and you are using mod_perl, you will need\n to restart Apache. Otherwise it will have stale code.\n\n - BackupPC should be ready to start. Don't forget to run it\n as user backuppc! The installation also contains\n a systemd\/backuppc.service script that can be installed so\n that BackupPC can auto-start on boot. This will also enable\n administrative users to start the server from the CGI interface.\n See systemd\/README.\n\nEnjoy!<\/code><\/pre>\n\n\n\n
.\/configure.pl --batch --cgi-dir \/var\/www\/cgi-bin\/BackupPC --data-dir \/var\/lib\/backuppc --hostname ubuntu20 --html-dir \/var\/www\/html\/BackupPC --html-dir-url \/BackupPC --install-dir \/usr\/local\/BackupPC<\/code><\/pre>\n\n\n\n
Configure Apache Web Server for BackupPC<\/h3>\n\n\n\n
cp ~\/backuppc\/BackupPC-*\/httpd\/BackupPC.conf \/etc\/apache2\/conf-available\/<\/code><\/pre>\n\n\n\n
sed -i 's\/Require local\/Require all granted\/' \/etc\/apache2\/conf-available\/BackupPC.conf<\/code><\/pre>\n\n\n\n
backuppc<\/code>.<\/p>\n\n\n\n
sed -i 's\/www-data\/backuppc\/g' \/etc\/apache2\/envvars<\/code><\/pre>\n\n\n\n
chmod u-s \/var\/www\/cgi-bin\/BackupPC\/BackupPC_Admin<\/code><\/pre>\n\n\n\n
Configure BackupPC Apache Basic Authentication<\/h4>\n\n\n\n
sed -i 's#^AuthUserFile.*$#AuthUserFile \/etc\/BackupPC\/.allowed#' \/etc\/apache2\/conf-available\/BackupPC.conf<\/code><\/pre>\n\n\n\n
sed -i 's\/^AuthName.*$\/AuthName \"Kifarunix-demo BackupPC Restricted Access\"\/' \/etc\/apache2\/conf-available\/BackupPC.conf<\/code><\/pre>\n\n\n\n
AuthUserFile<\/strong><\/code> parameter above. For example, to create web authentication user called
kifarunixadmin<\/code>;<\/p>\n\n\n\n
htpasswd -c \/etc\/BackupPC\/.allowed kifarunixadmin<\/code><\/pre>\n\n\n\n
kifarunixuser<\/code>.<\/p>\n\n\n\n
htpasswd \/etc\/BackupPC\/.allowed kifarunixuser<\/code><\/pre>\n\n\n\n
chmod 666 \/etc\/BackupPC\/.allowed<\/code><\/pre>\n\n\n\n
chown backuppc:backuppc \/etc\/BackupPC\/.allowed<\/code><\/pre>\n\n\n\n
Configure BackupPC Administrative User<\/h4>\n\n\n\n
kifarunixadmin<\/strong><\/code> user as BackupPC admin.<\/p>\n\n\n\n
vim \/etc\/BackupPC\/config.pl<\/code><\/pre>\n\n\n\n
$Conf{CgiAdminUserGroup} = 'kifarunixadmin';\n$Conf{CgiAdminUsers} = 'kifarunixadmin';<\/code><\/pre>\n\n\n\n
Define BackupPC Client Backup User<\/h3>\n\n\n\n
$Conf{RsyncSshArgs} = [\n '-e', '$sshPath -l root<\/strong>',\n];<\/code><\/pre>\n\n\n\n
backuppc<\/strong><\/code>, on every client to backup
which is only allowed to run rsync command with sudo rights<\/code> for backup purposes. Therefore, change this user accordingly.<\/p>\n\n\n\n
$Conf{RsyncSshArgs} = [\n '-e', '$sshPath -l backuppc<\/strong>',\n];<\/code><\/pre>\n\n\n\n
Enable BackupPC Apache configuration and CGI modules;<\/h4>\n\n\n\n
a2enconf BackupPC<\/code><\/pre>\n\n\n\n
a2enmod cgid<\/code><\/pre>\n\n\n\n
a2dissite 000-default.conf<\/code><\/pre>\n\n\n\n
mv \/var\/www\/html\/index.html \/var\/www\/html\/index.html.old<\/code><\/pre>\n\n\n\n
sed -i 's\/Options Indexes FollowSymLinks\/Options -Indexes +FollowSymLinks\/' \/etc\/apache2\/apache2.conf<\/code><\/pre>\n\n\n\n
echo -e 'ServerSignature Off\\nServerTokens Prod' >> \/etc\/apache2\/apache2.conf<\/code><\/pre>\n\n\n\n
apachectl -t<\/code><\/pre>\n\n\n\n
Syntax OK<\/code><\/pre>\n\n\n\n
systemctl enable --now apache2<\/code><\/pre>\n\n\n\n
systemctl restart apache2<\/code><\/pre>\n\n\n\n
Running BackupPC Service<\/h3>\n\n\n\n
cp ~\/backuppc\/BackupPC-*\/systemd\/backuppc.service \/etc\/systemd\/system\/<\/code><\/pre>\n\n\n\n
sed -i 's\/^#Group\/Group\/' \/etc\/systemd\/system\/backuppc.service<\/code><\/pre>\n\n\n\n
sed -i 's#PIDFile=\/var\/run\/#PIDFile=\/run\/#' \/etc\/systemd\/system\/backuppc.service<\/code><\/pre>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\n
systemctl enable --now backuppc<\/code><\/pre>\n\n\n\n
systemctl status backuppc<\/code><\/pre>\n\n\n\n
\u25cf backuppc.service - BackupPC server\n Loaded: loaded (\/etc\/systemd\/system\/backuppc.service; enabled; vendor preset: enabled)\n Active: active (running) since Sun 2020-05-17 19:29:38 UTC; 7s ago\n Main PID: 3772 (BackupPC)\n Tasks: 1 (limit: 2283)\n Memory: 8.6M\n CGroup: \/system.slice\/backuppc.service\n \u2514\u25003772 \/usr\/bin\/perl \/usr\/local\/BackupPC\/bin\/BackupPC\n\nMay 17 19:29:38 ubuntu20 systemd[1]: Started BackupPC server.<\/code><\/pre>\n\n\n\n
Accessing BackupPC Web User Interface<\/h2>\n\n\n\n
ufw allow 80\/tcp<\/code><\/pre>\n\n\n\n
http:\/\/server_IP_OR_hostname\/BackupPC_Admin<\/code><\/strong>.<\/p>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Reference<\/h3>\n\n\n\n
Other Related Tutorials<\/h3>\n\n\n\n