UdelaRInterior / ansible-backuppc

BackupPC ansible role for Debian
GNU General Public License v2.0
1 stars 0 forks source link

BackupPC Server Ansible role

This role, backuppc_server installs and configures a BackupPC server on a Debian GNU/Linux operating system. It initially worked on Debian Jessie, and is maintained up to Debian Buster. It probably can work on Ubuntu or other Debian-based systems, but it wasn't tested (PR and other contributions accepted).

It has a sister role BackupPC client to configure client hosts that will be backed up by the BackupPC server.

Description

This role installs and configures backuppc debian package, including ther creation of an ssh key for the backuppc user, as well as passwords and e-mails for web backuppc users. Optionally, it can also (by default it does) configure Apache2 for https web access to BackupPC interface, using either a self-signed certificate, a certbot one (generated elsewhere), or your own one.

backuppc_client role configures clients' accounts in their BackupPC server, as well as server ssh access to the client, to perform backups. But clients can also be configured manually, or by any other mean.

Notes

Role Variables

BackupPC package

There is no reason to change the following variables, there are more to centralise values than to be modified. Note that they are note taken into account in debial packages configuration.

BackupPC configuration variables

These are the most important configuration variables of the role.

See file templates/etc/backuppc/config.pl.j2 and BackupPC documentation for variables' reoles explanation and possible values. Only most significant parameters are mentionned here.

The role's variables are named with the namespace prefix backuppc_srv_ followed by the BackupPC config.pl file parameter name. Note that half of the name is in snake_case and half in CamelCase.

What to backup and when to do it

The following parameters can be overwritten in a per client bases. See backuppc_client role

For instance, the following configuration parameters:

backuppc_RsyncShareName:
- /etc/gitlab
- /var/opt/gitlab

backuppc_srv_BackupFilesOnly:
  # Configuration archives fo GitLab instance:
  "/etc/gitlab":
    - /gitlab.rb
    - /gitlab-secrets.json
  # Gotlab backup file
  "/var/opt/gitlab":
    - /backups/dump_backuppc_gitlab_backup.tar

will perform the backup of the three needed file of a GitLab instance. (dump_backuppc_gitlab_backup.tar is built by a script just before the dump, see backuppc_client role's documentation

Email reminders, status and messages

CGI user interface configuration settings

Can be overridden in the per-client config.pl

See also README of backuppc-client role for detailed client variables.

BackuPC CGI interface / web users

backuppc_srv_web_users: List of web user accounts data for BackupPC (Default value is empty). It is a list of dicts, each one defing a user account with the following parameters:

Usernames and their password hashcode will be configured in the /etc/backuppc/htpasswd/ of the host.

An htpasswd hash code for a user and a password can be obtaind running:

htpasswd -n user 

htpasswd utility is installed in linux with apache2-utils debian package.

In backuppc_client role, you will be able to configure these users in backuppc_server_web_main_user and backuppc_server_web_other_users variables.

Apache2 configuration

Apache2 parameters

SSL Configuration

The role can user either valide certificates generated elsewhere by Certbot, or the ssl-certs package's self-signed certificate.
Configuration of SSLCertificateFile and SSLCertificateKeyFile for

Previous flag defines the variables backuppc_srv_apache_ssl_cert_file and backuppc_srv_apache_ssl_cert_key_file used for Apache configuration of ssl certificates. You can overwrithe these variables with custom values, in which case porevious flag will be unuseful.

Access control

Notes

About HTTP

This role does now a basic but complete installation of Apache, with htpasswd authentication.

It also configures emails in the /etc/aliases, that should be handled by any MTA (that should be configured with the ability to send mails elsewhere)

About ssh access for backups

This role generates a backuppc SSH public key. The backuppc_client role deploys it on each client.

Example Playbook

- name: Configuration of my BackupPC server
  hosts: backup.mydomain.org
  remote_user: deploy
  become: yes

  vars:
    backuppc_srv_server_name: backup.mydomain.org
    backuppc_srv_RsyncShareName:
      - /
    backuppc_srv_FullKeepCnt: 4, 0, 4, 0, 0, 2 
    backuppc_srv_apache_ssl_certbot: false
    backuppc_srv_web_users: 
    - name: backuppc
      password: '{{ vault_secret }}'
      mail: me@domain.org
    - name: user
      htpasswd_hash: 'user2:$apr1$70okuQfp$/PB1pKZ0YXi6cTGL/yHXs1' 
      mail: me@domain.org

  - role: udelarinterior.backuppc_server

will install ando configure BackupPC and Apache2 in backup.mydomain.org host, with default self-signed ceertificates.

License

GPLv3

Author Information

Original role Emilien M enhanced by Víctor Torterola and Daniel Viñar