Categories: Docker

UrBackup: installation and configuration with docker

If you want to backup your Raspberry Pi, or maybe you want to do incremental backups for your laptop (it works both for Linux and Windows!) UrBackup is the right solution!

Urbackup is an open source tool that allows you to backup your data in a very easily way. It’s an awesome project and you can find more information on the UrBackup official website or in the GitHub page.

After some months that my backups are regularly saved every six hours I decided to write this tutorial. A thing that bothered me a lot is that in this moment there isn’t a nice tutorial that explain you all the most common setting for a selfhosted solution.

This tutorial require to have Docker and Docker-compose already installed.

Run the container

Open your server terminal and run these two commands.

mkdir urbackup && cd urbackup

nano docker-compose.yml

Now paste this in the editor. I took this docker compose file from the official docker image page on Docker Hub and I modified it.

version: '2'

services:
  urbackup:
    image: uroni/urbackup-server:latest
    container_name: urbackup
    restart: unless-stopped
    environment:
      - PUID=1000 # Enter the UID of the user who should own the files here
      - PGID=1000  # Enter the GID of the user who should own the files here
      - TZ=Europe/Berlin # Enter your timezone
    volumes:
      - ./urbackup:/var/urbackup
      - ./backups:/backups
      # Uncomment the next line if you want to bind-mount the www-folder
      #- /path/to/wwwfolder:/usr/share/urbackup
    network_mode: "host"
    # Activate the following two lines for BTRFS support
    #cap_add:
    #  - SYS_ADMIN

CTRL+X to save.

Run sudo docker-compose up -d

When it asks you if to use dattobd or not, select 1. We need to use dattobd because in this way we can backup running databases. This is very convenient, because otherwise we would have to stop the databases.

Go on  http://YOUR_IP:55414/

Now I took a while before to understand how to setup the admin password.

Simply go to Settings>Users and change / add the password for the admin user.

Install dattobd

The UrBackup installation is completed, now we have to install dattobd.

You can find here the instructions to install dattobd for your distro. I’m using Ubuntu 20 so I’ll run.

sudo apt-key adv --fetch-keys https://cpkg.datto.com/DATTO-PKGS-GPG-KEY
echo "deb [arch=amd64] https://cpkg.datto.com/datto-deb/public/$(lsb_release -sc) $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/datto-linux-agent.list
sudo apt-get update
sudo apt-get install dattobd-dkms dattobd-utils

Add new Linux clients on UrBackup

Once that the server is installed add a new client. Choose Internet client, in this way it’s gonna do the backups also outside your home/lan (if you natted the server).

It gives you a string like this one, just copy and paste it and run it. Just check if the ip is the private and, in case that you want it to work also from outside your home, put your public ip.

If you see authkey in my case is equal to XXXXXXX, when you copy the code from the server, it gives you a random authkey, it’s gonna be the authentication of the client.

PRIVATE_IP is your private ip. Like 192.168.1.n. If you want to make it avalaible from outside your network put your public ip or a domain like freemyip.com

TF=`mktemp` && wget "http://PRIVATE_IP:55414/x?a=download_client&lang=it_IT&clientid=1&authkey=XXXXXXXXX&os=linux" -O $TF && sudo sh $TF; rm -f $TF

Once that you added the client you have to configure it. Maily you have to setup which folder to backup.

List of saved directories

sudo urbackupclientctl list

Save a directory (you can add how many directories you want)

sudo urbackupclientctl add-backupdir -d /var/lib/docker/volumes
sudo urbackupclientctl add-backupdir -d /home/ale

Remove a directory

sudo urbackupclientctl add-backupdir -d /home/ale

Allow the restore from the admin panel.

RESTORE=server-confirms is the option that we have to enable.

sudo nano /etc/default/urbackupclient

# Defaults for urbackup_client initscript
# sourced by /etc/init.d/urbackupclientbackend
# installed at /etc/default/urbackupclient by the maintainer scripts

#
# This is parsed as a key=value file
#

#logfile name
LOGFILE="/var/log/urbackupclient.log"

#Either debug,warn,info or error
LOGLEVEL=warn

#Max size of the log file before rotation
#Disable if you are using logrotate for
#more advanced configurations (e.g. with compression)
LOG_ROTATE_FILESIZE=20971520

#Max number of log files during rotation
LOG_ROTATE_NUM=10

#Tmp file directory
DAEMON_TMPDIR="/tmp"

# Valid settings:
#
# "client-confirms": If you have the GUI component the currently active user
#                    will need to confirm restores from the web interface.
#                    If you have no GUI component this will cause restores
#                    from the server web interface to not work
# "server-confirms": The server will ask the user starting the restore on
#                    the web interface for confirmation
# "disabled":        Restores via web interface are disabled.
#                    Restores via urbackupclientctl still work
#
RESTORE=server-confirms

#If true client will not bind to any external network ports (either true or false)
INTERNET_ONLY=true

Now everything should work fine and the backup should start after some minutes.

From the Backups panel you should now be able to restore a file or a folder just with one click.

Urbackup panel

Uninstall or restart the UrBackup client

If you want to restart the UrBackup client just run the first and the second command.

The last command is going to uninstall the UrBackup client.

sudo service urbackupclientbackend stop
sudo service urbackupclientbackend start
sudo uninstall_urbackupclient

If you encountered in any error, feel free to ask here or on the official forum.

Alessandro Oppo

Alessandro è un milanese che vorrebbe scappare da Milano, è appassionato di informatica ma vorrebbe vivere senza telefono, è un artigiano eppure vorrebbe robotizzare tutto, impara una cosa e già vorrebbe studiare dell’altro. Autodidatta da sempre, gli piace sbattere la testa finché tutto non funziona come vuole lui, spesso ci riesce anche! Visita il suo blog personale alexoppo.com Il motto che si ripete dentro la testa è: “Se ci sono riusciti gli altri ci posso riuscire anche io”.

Share
Published by
Alessandro Oppo
Tags: backupdocker

Recent Posts

Ponti sospesi: cosa abbiamo sbagliato? cosa si potrebbe fare?

Poco prima di Natale ho avuto la fortuna di poter partecipare a un evento chiamato…

4 mesi ago

Siamo quel che facciamo? – racconto breve

Armando quel giorno era particolarmente stanco. Tutto, per quanto andasse bene, sembrava metterlo sotto pressione.…

9 mesi ago

Il limite è sempre la mente – Racconto breve

Armando guardò l’orologio e vide il proprio riflesso sul quadrante bianco. Il riflesso però non…

10 mesi ago

L’ultimo giorno del carcere – Racconto breve

I muri sono muri, lo sono sempre, anche quando le porte sono aperte. Era la…

10 mesi ago

Riflessioni sul carcere

Pochi di noi riflettono sull’esistenza nella nostra società del carcere. Il carcere è la concretizzazione…

12 mesi ago

Come dovremmo dialogare secondo me

Spesso intraprendiamo delle conversazioni e delle chiacchierate piuttosto inconsapevolmente. Voglio dire che non siamo molto…

12 mesi ago