{"id":2137,"date":"2020-07-31T10:25:41","date_gmt":"2020-07-31T07:25:41","guid":{"rendered":"https:\/\/upcloud.com\/global\/us\/resources\/tutorials\/get-started-backuppc-ubuntu\/"},"modified":"2020-07-31T10:25:41","modified_gmt":"2020-07-31T07:25:41","slug":"get-started-backuppc-ubuntu","status":"publish","type":"tutorial","link":"https:\/\/upcloud.com\/global\/resources\/tutorials\/get-started-backuppc-ubuntu\/","title":{"rendered":"How to get started with BackupPC on Ubuntu"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">BackupPC is a highly efficient backup system that requires no installations on the hosts to be backed up making it very easy to orchestrate. It features global deduplication, which allows you to store enormous amounts of backups in a small space. Deduplication is used during transfer, making it very good for backups over the internet. It also features compression, further minimizing storage usage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial describes how to install and orchestrate BackupPC 4 on an UpCloud cloud server using Ubuntu or Debian operating system.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/signup.upcloud.com\/\">Test hosting on UpCloud!<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Deploying BackupPC cloud server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">BackupPC will run on all available server plans, so you can start with a small one and simply upgrade to accommodate more clients to back up as your needs increase.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As a rule of thumb, 1&nbsp;<b>core<\/b>&nbsp;per concurrent backup is plenty. A single full client backup takes anything between a few seconds and a few hours to complete.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For&nbsp;<b>memory<\/b>, just go with the fixed plans according to your CPU needs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For&nbsp;<b>storage<\/b>, this tutorial will optimize cost and performance by splitting the data on the instance and HDD storage. This approach will place the \u2018pc\u2019 folder (somewhat equivalent to a database) on the instance root and the \u2018cpool\u2019 folder (akin to object storage) on separate storage. If the instance storage is sufficient as is, you can simply ignore adding it, the script below will adapt automatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then for the operating system, choose Ubuntu 18.04 LTS or Debian GNU\/Linux 10.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/storage-setup-backuppc.png\" alt=\"Storage setup for BackupPC cloud server\" class=\"wp-image-16188\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once all set, click the <em>Deploy<\/em> button at the bottom of the page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The deployment will only take a moment, after which you\u2019ll receive the root password via your chosen delivery method, email by default. With the server deployed and the password at hand, you can continue with the BackupPC installation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing BackupPC<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The installation is based on this <a rel=\"noopener\" href=\"https:\/\/github.com\/backuppc\/backuppc\/wiki\/Installing-BackupPC-4-from-tarball-or-git-on-Ubuntu\" target=\"_blank\">BackupPC Wiki page<\/a>. It is completely automated and will make use of additional storage is available on the instance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once the server is has been created, connect to your cloud server using SSH. Include the following additional parameter to bind the localhost:80 on the BackupPC cloud server to your local 8888 port:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh -L 8888:localhost:80 root@<span style=\"color: #ff0000;\">&lt;your-server-ip&gt;<\/span><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When logged in, first, set up the storage with this handy script below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo \"if [[ -e \/dev\/vdb ]]; then mkfs.ext4 \/dev\/vdb; mkdir -p \/srv\/backuppc\/cpool; echo '\/dev\/vdb \/srv\/backuppc\/cpool ext4 defaults 0 0' &gt;&gt; \/etc\/fstab; mount -a; fi\" | bash<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, download and run the installation script with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget -q -O -&nbsp;https:\/\/gitlab.molnix.com\/molnix-open-source\/backuppc-ubuntu-installer\/-\/raw\/master\/backuppc-ubuntu-installer&nbsp;| bash<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The installation process might take a little while but once done, you should see an output like below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Ok, 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!<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With the BackupPC installed, you can get started setting up backups. To enable this, you\u2019ll need the two following keys.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The password for <tt>backuppc<\/tt> username:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat password<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The public key needed to grant the BackupPC server access to the clients:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat \/var\/lib\/backuppc\/.ssh\/id_rsa.pub<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With the required credentials available, continue in the next section on how to configure BackupPC.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring BackupPC<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">BackupPC provides a convenient admin panel for easier backup management but it is configured to only grant access locally. The easiest way to connect to it is over an SSH tunnel. By using the SSH command as instructed in the previous section, you get to access the localhost of your cloud server from your web browser.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the BackupPC Web admin by going to <code>http:\/\/localhost:8888\/BackupPC_Admin<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Log in using <tt>backuppc<\/tt> username and the password output by the <tt>cat password<\/tt> command above.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/backuppc-admin.png\" alt=\"BackupPC admin panel\" class=\"wp-image-16186\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then configure your BackupPC as needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At a minimum, you should enable rsync over SSH to back up clients efficiently. Go to the Xfer configuration in the Edit Config menu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Edit Config -&gt; Xfer \u2013 XferMethod: rsync.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enable <tt>rsync<\/tt> by selecting it from the first drop-down menu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then click the Save button at the top to confirm the changes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/enable-rsync-config-backuppc.png\" alt=\"Enabling rsync config in BackupPC\" class=\"wp-image-16187\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all! Your BackupPC server is now ready to start making backups. Continue below with how to add clients for backing up.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding clients<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By using rsync to facilitate the backup, adding a client is as simple as adding them to the \/etc\/BackupPC\/hosts list and including the BackupPC public SSH key. For each new client, you only need to do the following:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1) Copy the public SSH key to <tt>\/root\/.ssh\/authorized_keys<\/tt> on the client:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh-copy-id -i \/var\/lib\/backuppc\/.ssh\/id_rsa.pub root@<span style=\"color: #ff0000;\">&lt;client-hostname&gt;<\/span><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2) Add the client hostname on BackupPC server using the web UI or on the command line:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo \"<span style=\"color: #ff0000;\">&lt;client-hostname&gt;<\/span> 0 backuppc\" &gt;&gt; \/etc\/BackupPC\/hosts<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For example, to back up the server itself, run the following two commands:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh-copy-id -i \/var\/lib\/backuppc\/.ssh\/id_rsa.pub root@localhost\necho \"localhost 0 backuppc\" &gt;&gt; \/etc\/BackupPC\/hosts<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this case, both are executed on the server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Taking and restoring backups<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once added, you\u2019ll see the <em>localhost<\/em> appear on the list of hosts for backing up.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/taking-backup-backuppc.png\" alt=\"Taking backup with BackupPC\" class=\"wp-image-16189\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">BackupPC will then manage the backups in the background without the need for user interaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the first backup process doesn\u2019t start automatically, try reloading the system configuration in <em>Admin Options<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once the first full backup has been completed, you can check the files in the backup by clicking the hostname and going to the <em>Browse backups<\/em> view.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/browse-backup-files-backuppc.png\" alt=\"Browsing backup files on BackupPC\" class=\"wp-image-16195\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then if ever needed, you can selectively restore files as you want!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Since the instance only serves over SSH, you can set up a firewall to only allow access on port 22.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to access the UI directly over the web, you should set up TLS, for example, using Let\u2019s Encrypt on a reverse proxy or on the local Apache configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For further support resources on BackupPC itself, check out the <a href=\"https:\/\/github.com\/backuppc\/backuppc\/wiki\/\" target=\"_blank\" rel=\"noopener\">BackupPC wiki<\/a>, <a href=\"https:\/\/backuppc.github.io\/backuppc\/BackupPC.html\" target=\"_blank\" rel=\"noopener\">BackupPC docs<\/a>, as well as <a href=\"https:\/\/sourceforge.net\/p\/backuppc\/mailman\/\" target=\"_blank\" rel=\"noopener\">mailing lists<\/a>. For example, a good practice is to set up the backup using a non-root account that has sudo rights. This is described in the docs.<\/p>\n","protected":false},"author":44,"featured_media":16243,"comment_status":"open","ping_status":"closed","template":"","community-category":[262,223],"class_list":["post-2137","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/tutorial"}],"author":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/comments?post=2137"}],"version-history":[{"count":0,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2137\/revisions"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=2137"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/community-category?post=2137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}