{"id":428,"date":"2018-08-19T11:35:11","date_gmt":"2018-08-19T08:35:11","guid":{"rendered":"http:\/\/kifarunix.com\/?p=428"},"modified":"2024-03-10T16:38:10","modified_gmt":"2024-03-10T13:38:10","slug":"how-to-install-and-configure-backuppc-as-a-backup-server-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-and-configure-backuppc-as-a-backup-server-on-ubuntu-18-04\/","title":{"rendered":"Install and Configure BackupPC as a Backup Server on Ubuntu 18.04"},"content":{"rendered":"\n
In this guide, we will learn how to install and configure BackupPC as a backup server on Ubuntu 18.04.<\/span><\/p>\n\n\n\n BackupPC 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 OS PCs and laptops to a server’s disk. BackupPC is highly configurable, easy to install and maintain. BackupPC requires no client as it is itself a client for several protocols that are handled by other services native to the client OS. Update and upgrade your system packages.<\/p>\n\n\n\n BackupPC can be install from Ubuntu repos using the package manager.<\/p>\n\n\n\n During installation you will be prompted to choose the type of web server to be configured. In our case, we will select option 1 to have Apache2 installed and configured for use with BackupPC. See the screenshot below.<\/p>\n\n\n\n During installation, BackupPC will set up an administrative user, backuppc. <\/strong>This user is used to administer various tasks such as access the BackupPC web dashboard, carry out backups…A default password is also generated for this user for logging into web interface. As a security measure, this password has to be changed. Run the following command to change the password:<\/p>\n\n\n\n BackupPC uses different methods to get backup data from clients:<\/p>\n\n\n\n In this tutorial we will be using rsync protocol as a backup method. For rsync to work, BackupPC requires passwordless SSH login for backuppc<\/strong> user to every client it will be getting backup data from. As a result, switch to backuppc user on BackupPC server and generate passwordless ssh keys and copy them to clients.<\/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 Copy the SSH public to root user on each client from which the BackupPC will collect backup data. Or more conveniently, 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 to backuppc user on the client.<\/p>\n\n\n\n Where 192.168.43.214 is my client IP address. Once you copy the key, you should be able to login without being prompted for a password.<\/p>\n\n\n\n NOTE<\/strong>: By default, BackupPC is using root user for backup. So if you happen to change the backup user, edit BackupPC configuration file, \/etc\/backuppc\/config.pl<\/strong> and edit the following lines by changing the root<\/strong> user to a user you are using for backup.<\/p>\n\n\n\n Since we will be using rsync protocol as a backup method, we will make changes under Rsync\/Rsyncd Configuration.<\/strong><\/p>\n\n\n\n Restart backuppc service to apply the changes.<\/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 didnt make the changes above.<\/p>\n\n\n\n or<\/p>\n\n\n\n If you changed you backup user to non-root user, Login to the client host and allow the non-user to run the rsync command without being prompted for password by adding the user to sudoers list. backuppc for our case.<\/p>\n\n\n\n You can run the command, which rsync<\/strong> to find the absolute path of rsync. 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. To do this, login to client, edit the ssh authorized key file and add the line, from=”backuppc_server_ip”,no-agent-forwarding,no-port-forwarding,no-pty,<\/strong> before the ssh-rsa <\/strong>keyword.<\/p>\n\n\n\n If all that is okay, login to BackupPC via browser using the link, http:\/\/backuppc_server_IP\/backuppc<\/strong> and proceed with configuration. To access the dashboard, login the web credentials created above.<\/p>\n\n\n\n Once you are logged in, you can now add the clients to backup. To add a client host, click on Edit Hosts<\/strong> on the left panel. This opens up a hosts configuration editor. Localhost is already added as the client but since we are only backing up remote clients, delete local hosts by clicking the delete<\/strong> button and click add<\/strong> to add you client hosts. For user, enter backuppc.<\/strong><\/p>\n\n\n\n When done adding hosts, click the save button to apply the changes.<\/p>\n\n\n\n Once the changes are saved, Configure backup data transfer settings, ie the protocol for backup method, In this case, we are using rsync. So still on the configuration editor, Click Xfer<\/strong> tab. Under Xfer Settings<\/strong>, click the dropdown and select rsync<\/strong>.<\/p>\n\n\n\n Click Save to apply the changes.<\/p>\n\n\n\n Next, we need to configure the paths to backup for the clients. Under Xfer Settings<\/strong>, check the overide box under RsyncShareName<\/strong> and add specific path to back up on client. For instance the home directory of a user. To exclude some path from backing up, check the box under under BackupFilesExclude<\/strong> on Include\/Exclude<\/strong> settings and add the parent path then paths to exclude. See the screenshot below.<\/p>\n\n\n\n Once done with settings, click save to apply changes.<\/p>\n\n\n\n In our next step, we will be configuring backup schedule, There are two types of backing up data, Incremental<\/strong> backup and full<\/strong> backup. Incremental backup is done daily and only 6 most recent backupps are kept while full backup happens every 7 days and only newest copy of data is backed up.<\/p>\n\n\n\n On the left pane, under Server<\/strong> settings, click Edit Config<\/strong> and navigate to Schedule<\/strong> tab.<\/p>\n\n\n\n You can make any changes as you see fit.<\/p>\n\n\n\n Now that we have done most configurations, let us run a manual backup on the two clients. To check the backup logs, click the LOG file<\/strong> link on the left panel. You can also check under following path on the server:<\/p>\n\n\n\n To check the backup summary, click the Host Summary<\/strong> link on the left pane, under Server<\/strong>.<\/p>\n\n\n\n To have an overview of what is backedup, click the host IP as shown in the summary above, then click Browse Backups<\/strong> > Backup number. There you go. That is basically what it takes to install and configure BackupPC and upto there, you have successfully configure a BackupPC server on Ubuntu 18.04 server.<\/p>\n\n\n\n Learn how to backup windows systems using BackupPC by following the link below;<\/p>\n\n\n\n
<\/span><\/p>\n\n\n\nInstall and Configure BackupPC on Ubuntu 18.04<\/h2>\n\n\n\n
apt update
apt upgrade<\/code><\/pre>\n\n\n\napt install -y backuppc<\/code><\/pre>\n\n\n\n
<\/figure>\n\n\n\n
htpasswd \/etc\/backuppc\/htpasswd backuppc<\/code><\/pre>\n\n\n\n
\n
su - backuppc<\/code><\/pre>\n\n\n\n
ssh-keygen<\/strong> \nGenerating public\/private rsa key pair.\nEnter file in which to save the key (\/var\/lib\/backuppc\/.ssh\/id_rsa): ENTER<\/strong> \nCreated directory '\/var\/lib\/backuppc\/.ssh'.\nEnter passphrase (empty for no passphrase): ENTER<\/strong>\nEnter same passphrase again: 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:qZUR\/Aohas\/rqkqp2ME1RHOA7D7vMiBvqXgGxr2RMoc backuppc@storagesrv01.example.com\nThe key's randomart image is:\n+---[RSA 2048]----+\n| . .+.... |\n| o..o. .. |\n| . ... ... |\n| +. . +. |\n|.ooo+ .S. |\n|+E+*o. o. |\n|o**+o.. |\n|=.Ooo |\n|O*o*o |\n+----[SHA256]-----+<\/code><\/pre>\n\n\n\n
useradd -m backuppc\npasswd backuppc<\/code><\/pre>\n\n\n\n
ssh-copy-id backuppc@192.168.43.214<\/code><\/pre>\n\n\n\n
vim \/etc\/backuppc\/config.pl<\/code><\/pre>\n\n\n\n
###########################################################################\n# Rsync\/Rsyncd Configuration\n# (can be overwritten in the per-PC log file)\n###########################################################################\n...\n# This setting only matters if $Conf{XferMethod} = 'rsync'.\n# Comment this line and add the same line with root user changed to backuppc<\/em><\/strong>\n#$Conf{RsyncClientCmd} = '$sshPath -q -x -l root $host $rsyncPath $argList+';<\/strong>\n$Conf{RsyncClientCmd} = '$sshPath -q -x -l backuppc<\/strong> $host $rsyncPath $argList+';\n...\n# Comment out these line and add the same line with root user changed to backuppc<\/em><\/strong>\n#$Conf{RsyncClientRestoreCmd} = '$sshPath -q -x -l root $host $rsyncPath $argList+';<\/strong>\n$Conf{RsyncClientRestoreCmd} = '$sshPath -q -x -l backuppc<\/strong> $host $rsyncPath $argList+';\n ...<\/code><\/pre>\n\n\n\n
systemctl restart backuppc<\/code><\/pre>\n\n\n\n
ssh -l backuppc client_IP whoami\nbackuppc<\/code><\/pre>\n\n\n\n
ssh -l root client_IP whoami\nroot<\/code><\/pre>\n\n\n\n
ssh backuppc@client_IP\nsu -\necho \"backuppc ALL=NOPASSWD: \/usr\/bin\/rsync\" > \/etc\/sudoers.d\/backuppc<\/code><\/pre>\n\n\n\n
If rsync command is not installed, run the following commands to install it.<\/p>\n\n\n\napt install rsync -y\nyum install rsync -y<\/code><\/pre>\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 AAAAB3NzaC1yc2EAAAADAQABAAABAQCeetRD5TDVQV7wZ9K7k2D2LvPWi5+h6rP8TDRxMhYuG1oA3uS4S0GpZYMOcMRjW+gaeMzBVNZ6qK\/g3TyPx7fNsQipXYp0RaJvS\/M\/k9QChYkzvxFad\/WXDkx5Wsqzf1CfT\/eGBMaFICTYePKQTnsPn5Vd2zS\/7t\/XfYLJCXTz8EANn02xz+rrRAHzAwB4ZJ1jOYh\/LnWUfezJrlZssV1XmZ5E\/Gw8+YSdYwvf5gn3asBnwbmTAOxBKmSgff14s61LPcPX\/cRjeBC2QmWTmWKTk5zxsnrUQA3eRJ5KL3yYLZrxxSeTc1dMMTVq1q9ra+nmkiTtINCi\/XXhO3Qu7YAT backuppc@storagesrv01.example.com<\/code><\/pre>\n\n\n\n
When you login, the dashboard below welcomes you.<\/p>\n\n\n\n<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
On the left pane, under Hosts<\/strong>, click on the dropdown button and select a client host.
Click on Edit Config<\/strong>. Then on the configuration editor, click Xfer<\/strong>.<\/p>\n\n\n\n<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Under Hosts<\/strong> on the top left panel, select the two hosts one by one and under Backup Summary<\/strong> > User Actions<\/strong>, click Start Full Backup<\/strong> and if everything is okay, you should see Reply from server ok.<\/p>\n\n\n\n<\/figure>\n\n\n\n
\/var\/lib\/backuppc\/pc\/ip_address_of_client<\/span>\/<\/code><\/pre>\n\n\n\n
<\/figure>\n\n\n\n
<\/p>\n\n\n\n