{"id":12055,"date":"2022-04-02T00:48:22","date_gmt":"2022-04-01T21:48:22","guid":{"rendered":"https:\/\/kifarunix.com\/?p=12055"},"modified":"2024-03-09T12:23:35","modified_gmt":"2024-03-09T09:23:35","slug":"install-backuppc-on-ubuntu","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-backuppc-on-ubuntu\/","title":{"rendered":"Install BackupPC on Ubuntu 22.04"},"content":{"rendered":"\n
In this guide, we will learn how to install BackupPC on Ubuntu 22.04. BackupPC<\/a> is a free, high-performance enterprise-grade backup software suite with a web-based frontend that 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 features:<\/p>\n\n\n\n Update and upgrade your system packages.<\/p>\n\n\n\n Once the system update is done, proceed to install BackupPC.<\/p>\n\n\n\n BackupPC is usually available on the default APT repositories:<\/p>\n\n\n\n As of this writing, BackupPC 4.4.0 is the current release as per the releases page<\/a>. The above confirms that the default Ubuntu 22.04 repos provide the latest BackupPC packages.<\/p>\n\n\n\n Hence, BackupPC can be installed using the package, Postfix is installed alongside BackupPC. During the installation, you will be prompted to configure it;<\/p>\n\n\n\n During the installation, you will be prompted to choose the web server to be used by BackupPC. Apache web server is used in this guide.<\/p>\n\n\n\n A default BackupPC administrative user, You can choose to copy the password provided or you can proceed and reset the password later by executing the command below;<\/p>\n\n\n\n BackupPC uses different protocols to get backup data from devices being backed up:<\/p>\n\n\n\n In this tutorial we are going to configure BackupPC to use the rsync<\/strong> protocol as a backup method. This is customizable per client basis as well.<\/p>\n\n\n\n To change the BackupPC backup protocol from SMB to Rsync, run the command below;<\/p>\n\n\n\n Also, by default, BackupPC is using root user run backup tasks.<\/p>\n\n\n\n However, in this guide, we are going to use a If you happen to change the backup user, edit BackupPC configuration file, BackupPC uses htpasswd user files to restrict access to web interface. <\/p>\n\n\n\n As such, you require a valid user in order to authenticate.<\/p>\n\n\n\n The Web authentication user and its hashed credential password is stored under the You can reset the password by running;<\/p>\n\n\n\n Allow external access to BackupPC, which is set to only allow connections from localhost.<\/p>\n\n\n\n This is how the BackupPC Apache config file looks like without comment lines;<\/p>\n\n\n\n Next, restart both backuppc and Apache service to apply the changes made above.<\/p>\n\n\n\n If UFW is running, allow external access to Apache.<\/p>\n\n\n\n For rsync to work, BackupPC requires passwordless SSH login for backuppc<\/strong> user (or any specific user used for backup<\/em>) to every client it will be getting backup data from, as per this setup.<\/p>\n\n\n\n This also means that you should create a dedicated backuppc user on the hosts you need to backup using the rsync protocol.<\/p>\n\n\n\n As a result, switch to backuppc user on BackupPC server and generate passwordless ssh keys and copy them to every host you want to backup.<\/p>\n\n\n\n This will opens up the sh shell. You can run bash command to launch bash shell.<\/p>\n\n\n\n Generate SSH key pair by running the following command;<\/p>\n\n\n\n Next, login to the system servers you want to backup and create an account on the client dedicated for backup purposes for example, create a backuppc user account on remote client and copy the public key to that user.<\/p>\n\n\n\n Now logout from client host and copy the SSH public key for backuppc user on BackupPC server to backuppc user on the client server to be backed up. Copy the keys while logged as backuppc user.<\/p>\n\n\n\n Where 192.168.43.214 is my client IP address.<\/p>\n\n\n\n Once you copy the key, you should be able to login without being prompted for a password.<\/p>\n\n\n\n Now, test the login to client with the backup user to ensure user can successfully login to client. You can use root user if you didn\u2019t make the changes above.<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n or<\/p>\n\n\n\n Sample output<\/p>\n\n\n\n If you changed you backup user to non-root user, Login to the client host as an administrative user and allow the non-user to run the rsync command with sudo rights without being prompted for password by adding the user to sudoers list. Run the command below to find the absolute path of rsync.<\/p>\n\n\n\n If rsync command is not installed, run the following commands to install it.<\/p>\n\n\n\n Next, update the sudoers file.<\/p>\n\n\n\n You may also want to disable ssh agent-forwarding, port-forwarding or even the pty for backuppc user logging in to the client from BackupPC.<\/p>\n\n\n\n To do this, login to client, edit the ssh authorized key file and add the line below before the Replace the Next, you can also configure ssh logins to backuppc user accounts on clients hosts from the BackupPC server only. This can be done by editing Add the line below to SSHd configuration to allow login to the client as backuppc from the BackupPC server only.<\/p>\n\n\n\n Reload SSH configurations<\/p>\n\n\n\n Once the configuration is done, login to BackupPC via browser using the address, You are prompted to authenticate before accessing the dashboard.<\/p>\n\n\n\n Use the When you login, you will land on BackupPC dashboard.<\/p>\n\n\n\n If you noticed, the localhost<\/strong>, which is the server running backuppc is already added as one of the backup hosts.<\/p>\n\n\n\n The backup tried to run but failed, due to some default backup protocol (tar) errors.<\/p>\n\n\n\n Since we are using rsync as a backup protocol in this guide, you need to update this for the localhost backup to run.<\/p>\n\n\n\n Hence, click on hostname (localhost for example)<\/strong> > edit config > Xfer<\/strong> > XferMethod > Rsync<\/strong>.<\/p>\n\n\n\n Update RsyncShareName<\/strong><\/p>\n\n\n\n Click Save<\/strong>.<\/p>\n\n\n\n Reset the local account password for backuppc user.<\/p>\n\n\n\n Keep the password save.<\/p>\n\n\n\n Install rsync and allow BackupPC user to execute rsync with sudo without password.<\/p>\n\n\n\n Copy the password generated above to server itself.<\/p>\n\n\n\n Initiate localhost backup.<\/p>\n\n\n\n Once the backup is running, you can see status under status menu.<\/p>\n\n\n\n You can now add more hosts to backup.<\/p>\n\n\n\n That is basically it on our guide on how to install BackupPC on Ubuntu.<\/p>\n\n\n\n Install and Setup Rsyslog Server on Ubuntu 22.04<\/a><\/p>\n\n\n\n Install Couchbase Server on Ubuntu 22.04\/Ubuntu 20.04<\/a><\/p>\n\n\n\n\n
Install BackupPC on Ubuntu 22.04<\/h2>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
apt-cache policy backuppc<\/code><\/pre>\n\n\n\n
\nbackuppc:\n Installed: (none)\n Candidate: 4.4.0-5ubuntu2\n Version table:\n 4.4.0-5ubuntu2 500\n 500 http:\/\/ke.archive.ubuntu.com\/ubuntu jammy\/main amd64 Packages\n<\/code><\/pre>\n\n\n\n
backuppc<\/code> by running the command below;<\/p>\n\n\n\n
apt install -y backuppc<\/code><\/pre>\n\n\n\n
Setup Postfix<\/h3>\n\n\n\n
\n
Choose Web Server<\/h3>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
Web Administrator Credentials<\/h3>\n\n\n\n
backuppc<\/code>, and its password is also created during the installation. This user is used to administer various tasks such as access to BackupPC web dashboard, carry out backups etc.<\/p>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
htpasswd \/etc\/backuppc\/htpasswd backuppc<\/code><\/pre>\n\n\n\n
Configuring BackupPC Server on Ubuntu 22.04<\/h3>\n\n\n\n
Define BackupPC Backup Protocol<\/h4>\n\n\n\n
\n
sed -i \"s\/$Conf{XferMethod} = 'smb';\/$Conf{XferMethod} = 'rsync';\/\" \/etc\/backuppc\/config.pl<\/code><\/pre>\n\n\n\n
Define BackupPC Backup User<\/h4>\n\n\n\n
backuppc<\/code> user to execute backup tasks.<\/p>\n\n\n\n
\/etc\/backuppc\/config.pl<\/code> and replace the root<\/strong> user with a user you are using for backup under the Rsync\/Rsyncd Configuration.<\/strong> <\/p>\n\n\n\n
sed -i '\/RsyncSshArgs\/s\/-l root\/-l backuppc\/' \/etc\/backuppc\/config.pl<\/code><\/pre>\n\n\n\n
Configure BackupPC Apache Authentication<\/h3>\n\n\n\n
\/etc\/backuppc\/htpasswd<\/code>.<\/p>\n\n\n\n
htpasswd \/etc\/backuppc\/htpasswd backuppc<\/code><\/pre>\n\n\n\n
sed -i 's\/local\/all granted\/' \/etc\/backuppc\/apache.conf<\/code><\/pre>\n\n\n\n
cat \/etc\/backuppc\/apache.conf | grep -vE '^$|^.*#'<\/code><\/pre>\n\n\n\n
\nAlias \/backuppc \/usr\/share\/backuppc\/cgi-bin\/\n<Directory \/usr\/share\/backuppc\/cgi-bin\/>\n\tAllowOverride None\n\t\t\t\t\t\n\tOptions ExecCGI FollowSymlinks\n\tAddHandler cgi-script .cgi\n\tDirectoryIndex index.cgi\n AuthUserFile \/etc\/backuppc\/htpasswd\n\tAuthType basic\n\tAuthName \"BackupPC admin\"\n <RequireAll>\n\t\tRequire all granted\n\t\tRequire valid-user\n\t<\/RequireAll>\n<\/Directory>\n<\/code><\/pre>\n\n\n\n
systemctl restart backuppc apache2<\/code><\/pre>\n\n\n\n
ufw allow WWW<\/code><\/pre>\n\n\n\n
Generate Backup User SSH Keys<\/h3>\n\n\n\n
su - backuppc<\/code><\/pre>\n\n\n\n
ssh-keygen<\/code><\/pre>\n\n\n\n
Generating public\/private rsa key pair.\nEnter file in which to save the key (\/var\/lib\/backuppc\/.ssh\/id_rsa): \nCreated directory '\/var\/lib\/backuppc\/.ssh'.\nEnter passphrase (empty for no passphrase): PRESS ENTER<\/strong>\nEnter same passphrase again: PRESS ENTER<\/strong>\nYour identification has been saved in \/var\/lib\/backuppc\/.ssh\/id_rsa\nYour public key has been saved in \/var\/lib\/backuppc\/.ssh\/id_rsa.pub\nThe key fingerprint is:\nSHA256:MjPsb8texAqx1uc0u2X3Pk7kJRftu4KiJPeoD4RnNcQ backuppc@bullseye.kifarunix-demo.com\nThe key's randomart image is:\n+---[RSA 3072]----+\n| .. |\n| .E .|\n| .o ..|\n| ...+.. ..|\n| . +X S * ..+|\n| +o * * o ooo|\n| o.o. + + .+ |\n| =o+o = o.o.|\n| .o**oo o++|\n+----[SHA256]-----+\n<\/code><\/pre>\n\n\n\n
Backup Linux Hosts using BackupPC<\/h3>\n\n\n\n
Create Backup User Account On Remote Clients<\/h4>\n\n\n\n
useradd -m backuppc<\/code><\/pre>\n\n\n\n
passwd backuppc<\/code><\/pre>\n\n\n\n
Copy BackupPC Server SSH Keys to Remote Clients<\/h4>\n\n\n\n
su - backuppc<\/code><\/pre>\n\n\n\n
ssh-copy-id backuppc@192.168.43.214<\/code><\/pre>\n\n\n\n
ssh -l backuppc client_IP whoami<\/code><\/pre>\n\n\n\n
backuppc<\/code><\/pre>\n\n\n\n
ssh -l root client_IP whoami<\/code><\/pre>\n\n\n\n
root<\/code><\/pre>\n\n\n\n
backuppc<\/code> user is used in this case.<\/p>\n\n\n\n
ssh admin@client_IP<\/code><\/pre>\n\n\n\n
which rsync<\/code><\/pre>\n\n\n\n
apt install rsync -y<\/code><\/pre>\n\n\n\n
yum install rsync -y<\/code><\/pre>\n\n\n\n
echo \"backuppc ALL=NOPASSWD: \/usr\/bin\/rsync\" | sudo tee \/etc\/sudoers.d\/backuppc<\/code><\/pre>\n\n\n\n
ssh-rsa<\/code> <\/strong>keyword.<\/p>\n\n\n\n
from=\u201dbackuppc_server_ip\u201d,no-agent-forwarding,no-port-forwarding,no-pty<\/code><\/pre>\n\n\n\n
backuppc_server_ip<\/code> with the IP address of the backuppc server.<\/p>\n\n\n\n
vim \/home\/backuppc\/.ssh\/authorized_keys<\/code><\/pre>\n\n\n\n
from=\"192.168.43.154\",no-agent-forwarding,no-port-forwarding,no-pty<\/strong> ssh-rsa AAAAB3NzaC1SSSc2EAAAADAQABAAABAQDYuDSNIPxQL6hNh6FeW4wj3hYJ+p42SD9BGVg5Rn6HuzIAi1zrU2pRceQ5VDRj5nXxSjs+oJJ4lXZ\/HTaUQDBFysVyIe9Sc4Z9Z5nmmmGWIJnKWfuvzSYbV2JbSJjcTfUPjH32DOvU+4PMdil\/4GjKW7pr8fyywl4XuhZMU6RfVw0LgzYuqzUQX5D6Q4MsgIN4HGqBsnVIBvSz2TcPc0hovtfKQMmUBQvp7L9Ob3AKuG01ZZznQ8Q6+eGL7EJHnS30h\/FLM8rKBxsvI6El8xog2E0\/ALnNGKWsg2NTEqWqQ3xpUDEnA6exgHEm+2xCuKAy1sAuSJHJHScUMLZIUE36t2+nB0Vn backuppc@backuppc.kifarunix-demo.com<\/code><\/pre>\n\n\n\n
sshd_config<\/code> file on the client and configuring as shown below;<\/p>\n\n\n\n
sudo vim \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n
Match Host 192.168.43.154\n AllowUsers backuppc<\/code><\/pre>\n\n\n\n
systemctl reload ssh<\/code><\/pre>\n\n\n\n
Accessing BackupPC Web User Interface<\/h3>\n\n\n\n
http:\/\/backuppc_server_IP or hostname\/backuppc<\/code>.<\/p>\n\n\n\n
backuppc<\/code><\/strong> web user credentials set above.<\/p>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
Backup Hosts using BackupPC<\/h3>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
passwd backuppc<\/code><\/pre>\n\n\n\n
apt install rsync<\/code><\/pre>\n\n\n\n
echo \"backuppc ALL=NOPASSWD: $(which rsync)\" | sudo tee \/etc\/sudoers.d\/backuppc<\/code><\/pre>\n\n\n\n
su - backuppc<\/code><\/pre>\n\n\n\n
ssh-copy-id backuppc@localhost<\/code><\/pre>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n