mirror of
https://github.com/borgbase/ansible-role-borgbackup.git
synced 2025-05-29 01:15:45 +02:00
Remove old test targets, consistent wording, remove tag
This commit is contained in:
parent
4428bbf4a7
commit
adc2e40ccb
@ -1,14 +1,16 @@
|
|||||||
# Ansible Role: BorgBackup Client
|
# Additional Examples
|
||||||
The following example installs and configures the Borgmatic client and also initializes the repo on the BackupServer.
|
|
||||||
|
## Use service user and copy SSH key to target server
|
||||||
|
|
||||||
|
Installs and configures the Borgmatic client and also initializes the repo on the remote backup server.
|
||||||
|
|
||||||
## Fullautomated Playbook with service user -> this has sudo power
|
|
||||||
```
|
```
|
||||||
- name: Configure backup
|
- name: Configure backup
|
||||||
hosts: test.lab
|
hosts: test.lab
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Get home of {{ borgbackup_user }}
|
- name: Get home of {{ borg_user }}
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ borgbackup_user }}"
|
name: "{{ borg_user }}"
|
||||||
state: present
|
state: present
|
||||||
register: user_info
|
register: user_info
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@ -21,9 +23,8 @@ The following example installs and configures the Borgmatic client and also init
|
|||||||
vars:
|
vars:
|
||||||
borg_encryption_passphrase: "CHANGEME"
|
borg_encryption_passphrase: "CHANGEME"
|
||||||
borg_repository: "USER@TARGET_SERVER:/PATH/TO/BACKUP"
|
borg_repository: "USER@TARGET_SERVER:/PATH/TO/BACKUP"
|
||||||
borgbackup_user: "srv_backup"
|
borg_user: "srv_backup"
|
||||||
borgbackup_group: "srv_backup"
|
borg_group: "srv_backup"
|
||||||
borg_repository: "{{ vault_borg.backup_user }}@{{ backup_server }}:{{ backup_path }}/{{ ansible_host }}"
|
|
||||||
borg_ssh_key_file_path: "{{ backup_user_info.home }}/.ssh/backup"
|
borg_ssh_key_file_path: "{{ backup_user_info.home }}/.ssh/backup"
|
||||||
borg_ssh_command: "ssh -i {{ borg_ssh_key_file_path }} -o StrictHostKeyChecking=no"
|
borg_ssh_command: "ssh -i {{ borg_ssh_key_file_path }} -o StrictHostKeyChecking=no"
|
||||||
borgmatic_timer: systemd
|
borgmatic_timer: systemd
|
||||||
@ -77,7 +78,7 @@ The following example installs and configures the Borgmatic client and also init
|
|||||||
|
|
||||||
- name: Init repository
|
- name: Init repository
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: "su - {{ borgbackup_user }} -c '/usr/local/bin/borgmatic rcreate --encryption keyfile --append-only'"
|
cmd: "su - {{ borg_user }} -c '/usr/local/bin/borgmatic rcreate --encryption keyfile --append-only'"
|
||||||
|
|
||||||
- name: Activate systemd service and timer
|
- name: Activate systemd service and timer
|
||||||
when:
|
when:
|
||||||
@ -99,7 +100,7 @@ The following example installs and configures the Borgmatic client and also init
|
|||||||
when: "item in services"
|
when: "item in services"
|
||||||
with_items:
|
with_items:
|
||||||
- borgmatic.service
|
- borgmatic.service
|
||||||
|
|
||||||
# bug: Need own section without masked else the timer are skipped
|
# bug: Need own section without masked else the timer are skipped
|
||||||
- name: Start borgmatic timers
|
- name: Start borgmatic timers
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
@ -109,4 +110,4 @@ The following example installs and configures the Borgmatic client and also init
|
|||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
with_items:
|
with_items:
|
||||||
- "borgmatic.timer"
|
- "borgmatic.timer"
|
||||||
```
|
```
|
35
README.md
35
README.md
@ -8,8 +8,7 @@ Works great with [BorgBase.com](https://www.borgbase.com) - Simple and Secure Ho
|
|||||||
|
|
||||||
Main features:
|
Main features:
|
||||||
- Set up Borg and Borgmatic
|
- Set up Borg and Borgmatic
|
||||||
- Add systemd timer random time
|
- Schedule regular backups using Cron or Systemd timer.
|
||||||
- Provision new remote [BorgBase.com](https://www.borgbase.com) repo for storing backups (optional)
|
|
||||||
|
|
||||||
|
|
||||||
## Example Playbook with root as backup user and Cron timer
|
## Example Playbook with root as backup user and Cron timer
|
||||||
@ -19,7 +18,7 @@ Main features:
|
|||||||
roles:
|
roles:
|
||||||
- role: m3nu.ansible_role_borgbackup
|
- role: m3nu.ansible_role_borgbackup
|
||||||
borg_encryption_passphrase: CHANGEME
|
borg_encryption_passphrase: CHANGEME
|
||||||
borg_repository: m5vz9gp4@m5vz9gp4.repo.borgbase.com:repo
|
borg_repository: ssh://m5vz9gp4@m5vz9gp4.repo.borgbase.com/./repo
|
||||||
borgmatic_timer: cron
|
borgmatic_timer: cron
|
||||||
borg_source_directories:
|
borg_source_directories:
|
||||||
- /srv/www
|
- /srv/www
|
||||||
@ -49,12 +48,12 @@ If you already use this role and use the user: "root" or the SSH key id_ed25519!
|
|||||||
roles:
|
roles:
|
||||||
- role: m3nu.ansible_role_borgbackup
|
- role: m3nu.ansible_role_borgbackup
|
||||||
borg_encryption_passphrase: CHANGEME
|
borg_encryption_passphrase: CHANGEME
|
||||||
borg_repository: m5vz9gp4@m5vz9gp4.repo.borgbase.com:repo
|
borg_repository: ssh://m5vz9gp4@m5vz9gp4.repo.borgbase.com/./repo
|
||||||
borgmatic_timer: systemd
|
borgmatic_timer: systemd
|
||||||
borg_ssh_key_file_path: "{{ backup_user_info.home }}/.ssh/backup"
|
borg_ssh_key_file_path: "{{ backup_user_info.home }}/.ssh/backup"
|
||||||
borg_ssh_command: "ssh -i {{ borg_ssh_key_file_path }} -o StrictHostKeyChecking=no"
|
borg_ssh_command: "ssh -i {{ borg_ssh_key_file_path }} -o StrictHostKeyChecking=no"
|
||||||
borgbackup_user: "srv_backup"
|
borg_user: "srv_backup"
|
||||||
borgbackup_group: "srv_backup"
|
borg_group: "srv_backup"
|
||||||
borg_source_directories:
|
borg_source_directories:
|
||||||
- /srv/www
|
- /srv/www
|
||||||
- /var/lib/automysqlbackup
|
- /var/lib/automysqlbackup
|
||||||
@ -89,26 +88,18 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/ansibl
|
|||||||
|
|
||||||
|
|
||||||
## Tags:
|
## Tags:
|
||||||
This Role supports the following ansible tags:
|
This role supports the following Ansible tags:
|
||||||
|
|
||||||
- `install_backup`: Tag for only run that part.
|
- `backup_install_helper` Install optional helper scripts from `files` folder. Currently only Docker.
|
||||||
- `backup_install_helper` Tag to additionally install the backup helper skripts. Currently only docker.
|
|
||||||
|
|
||||||
### Example
|
|
||||||
To install the helper scrit.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook test.example.com -t backup_install_helper
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Role Variables
|
## Role Variables
|
||||||
|
|
||||||
### Required Arguments
|
### Required Variables
|
||||||
- `borg_repository`: Full path to repository. Your own server or [BorgBase.com](https://www.borgbase.com) repo. Not required when using auto creation of repositories. Can be a list if you want to backup to multiple repositories.
|
- `borg_repository`: Full path to repository. Your own server or [BorgBase.com](https://www.borgbase.com) repo.
|
||||||
|
Can be a list if you want to backup to multiple repositories.
|
||||||
|
|
||||||
|
### Optional Variables
|
||||||
### Optional Arguments
|
|
||||||
- `borg_dep_packages`: Dependancy Packages to install `borg(backup)` and `borgmatic`.
|
- `borg_dep_packages`: Dependancy Packages to install `borg(backup)` and `borgmatic`.
|
||||||
- `borg_distro_packages`: contains the names of distributions packages for `borg(backup)` and `borgmatic`, only used if `borg_install_method` is set to `package`.
|
- `borg_distro_packages`: contains the names of distributions packages for `borg(backup)` and `borgmatic`, only used if `borg_install_method` is set to `package`.
|
||||||
- `borg_encryption_passcommand`: The standard output of this command is used to unlock the encryption key.
|
- `borg_encryption_passcommand`: The standard output of this command is used to unlock the encryption key.
|
||||||
@ -142,8 +133,8 @@ $ ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook test.example.com -t backup_insta
|
|||||||
- `borgmatic_store_ctime`: Store ctime into archive. Defaults to `true`
|
- `borgmatic_store_ctime`: Store ctime into archive. Defaults to `true`
|
||||||
- `borgmatic_version`: Force a specific borgmatic version to be installed
|
- `borgmatic_version`: Force a specific borgmatic version to be installed
|
||||||
|
|
||||||
- `borgbackup_user`: Name of the User to create Backups (Service Account)
|
- `borg_user`: Name of the User to create Backups (service account)
|
||||||
- `borgbackup_group`: Name of the Group to create Backups (Service Account)
|
- `borg_group`: Name of the Group to create Backups (service account)
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
@ -36,9 +36,9 @@ borgmatic_hooks:
|
|||||||
# See: https://torsion.org/borgmatic/docs/how-to/deal-with-very-large-backups/#check-frequency
|
# See: https://torsion.org/borgmatic/docs/how-to/deal-with-very-large-backups/#check-frequency
|
||||||
borgmatic_checks:
|
borgmatic_checks:
|
||||||
- name: repository
|
- name: repository
|
||||||
frequency: "2 Weeks"
|
frequency: "4 weeks"
|
||||||
- name: archives
|
- name: archives
|
||||||
frequency: "1 month"
|
frequency: "6 weeks"
|
||||||
borgmatic_check_last: 3
|
borgmatic_check_last: 3
|
||||||
borgmatic_store_atime: true
|
borgmatic_store_atime: true
|
||||||
borgmatic_store_ctime: true
|
borgmatic_store_ctime: true
|
||||||
@ -46,6 +46,6 @@ borgmatic_relocated_repo_access_is_ok: false
|
|||||||
borgmatic_version: false
|
borgmatic_version: false
|
||||||
|
|
||||||
borg_venv_path: "/opt/borgmatic"
|
borg_venv_path: "/opt/borgmatic"
|
||||||
borgbackup_user: "root"
|
borg_user: "root"
|
||||||
borgbackup_group: "root"
|
borg_group: "root"
|
||||||
...
|
...
|
||||||
|
@ -16,7 +16,7 @@ argument_specs:
|
|||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
description: |
|
description: |
|
||||||
Contains the names of distributions packages for borg(backup) and borgmatic,
|
Contains the names of distributions packages for borg(backup) and borgmatic,
|
||||||
only used if `borg_install_method` is set to package
|
only used if `borg_install_method` is set to package
|
||||||
borg_pip_packages:
|
borg_pip_packages:
|
||||||
type: str
|
type: str
|
||||||
@ -32,8 +32,8 @@ argument_specs:
|
|||||||
default: pip
|
default: pip
|
||||||
description: |
|
description: |
|
||||||
By default pip is used to install borgmatic.
|
By default pip is used to install borgmatic.
|
||||||
To install via your distributions package manager set this to package and (if needed)
|
To install via your distributions package manager set this to package and (if needed)
|
||||||
overwrite the borg_distro_packages variable to contain your distributions package names
|
overwrite the borg_distro_packages variable to contain your distributions package names
|
||||||
required to install borgmatic.
|
required to install borgmatic.
|
||||||
Note that many distributions ship outdated versions of borgbackup and borgmatic; use at your own risk.
|
Note that many distributions ship outdated versions of borgbackup and borgmatic; use at your own risk.
|
||||||
borgmatic_config_name:
|
borgmatic_config_name:
|
||||||
@ -41,11 +41,11 @@ argument_specs:
|
|||||||
required: false
|
required: false
|
||||||
default: config.yaml
|
default: config.yaml
|
||||||
description: Name to use for the borgmatic config file.
|
description: Name to use for the borgmatic config file.
|
||||||
borgbackup_user:
|
borg_user:
|
||||||
type: str
|
type: str
|
||||||
default: root
|
default: root
|
||||||
description: Name of the User to create Backups (Service Account)
|
description: Name of the User to create Backups (Service Account)
|
||||||
borgbackup_group:
|
borg_group:
|
||||||
type: str
|
type: str
|
||||||
default: root
|
default: root
|
||||||
description: Name of the Group to create Backups (Service Account)
|
description: Name of the Group to create Backups (Service Account)
|
||||||
@ -137,11 +137,11 @@ argument_specs:
|
|||||||
description: Number of weekly archives to keep.
|
description: Number of weekly archives to keep.
|
||||||
keep_monthly:
|
keep_monthly:
|
||||||
type: int
|
type: int
|
||||||
required: false
|
required: false
|
||||||
description: Number of monthly archives to keep.
|
description: Number of monthly archives to keep.
|
||||||
keep_yearly:
|
keep_yearly:
|
||||||
type: int
|
type: int
|
||||||
required: false
|
required: false
|
||||||
description: Number of yearly archives to keep.
|
description: Number of yearly archives to keep.
|
||||||
borgmatic_checks:
|
borgmatic_checks:
|
||||||
type: List
|
type: List
|
||||||
@ -152,8 +152,8 @@ argument_specs:
|
|||||||
Defaults to "repository" and "archives".
|
Defaults to "repository" and "archives".
|
||||||
Set to "disabled" to disable all consistency checks.
|
Set to "disabled" to disable all consistency checks.
|
||||||
"repository" checks the consistency of the repository,
|
"repository" checks the consistency of the repository,
|
||||||
"archives" checks all of the archives, "data" verifies
|
"archives" checks all of the archives, "data" verifies
|
||||||
the integrity of the data within the archives, and
|
the integrity of the data within the archives, and
|
||||||
"extract" does an extraction dry-run of the most recent archive.
|
"extract" does an extraction dry-run of the most recent archive.
|
||||||
Note that "data" implies "archives".
|
Note that "data" implies "archives".
|
||||||
borgmatic_check_last:
|
borgmatic_check_last:
|
||||||
|
@ -6,18 +6,12 @@ driver:
|
|||||||
platforms:
|
platforms:
|
||||||
- name: archlinux-latest
|
- name: archlinux-latest
|
||||||
image: archlinux:latest
|
image: archlinux:latest
|
||||||
- name: centos-7
|
|
||||||
image: centos:7
|
|
||||||
- name: almalinux-8
|
|
||||||
image: almalinux:8
|
|
||||||
- name: almalinux-9
|
- name: almalinux-9
|
||||||
image: almalinux:9
|
image: almalinux:9
|
||||||
- name: fedora-latest
|
- name: fedora-latest
|
||||||
image: fedora:latest
|
image: fedora:latest
|
||||||
- name: debian-bullseye
|
- name: debian-bullseye
|
||||||
image: debian:bullseye
|
image: debian:bullseye
|
||||||
- name: ubuntu-bionic
|
|
||||||
image: ubuntu:bionic
|
|
||||||
- name: ubuntu-latest
|
- name: ubuntu-latest
|
||||||
image: ubuntu:latest
|
image: ubuntu:latest
|
||||||
provisioner:
|
provisioner:
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Install borgbackup
|
- name: Install borgbackup
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Ensure legacy hooks aren't used
|
- name: Ensure legacy hooks aren't used
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
|
@ -3,13 +3,11 @@
|
|||||||
# Since we cannot be sure that this FSH is compatible we will determine it.
|
# Since we cannot be sure that this FSH is compatible we will determine it.
|
||||||
- name: Get home dir
|
- name: Get home dir
|
||||||
when:
|
when:
|
||||||
- borgbackup_user == "root"
|
- borg_user == "root"
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Get home if borgbackup_user == "root"
|
- name: Get home if borg_user == "root"
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ borgbackup_user }}"
|
name: "{{ borg_user }}"
|
||||||
state: present
|
state: present
|
||||||
register: user_info
|
register: user_info
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@ -19,11 +17,9 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
backup_user_info: "{{ user_info }}"
|
backup_user_info: "{{ user_info }}"
|
||||||
|
|
||||||
- name: Create User if borgbackup_user != "root"
|
- name: Create user if borg_user != "root"
|
||||||
when:
|
when:
|
||||||
- borgbackup_user != "root"
|
- borg_user != "root"
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: noauto_create_backup_user_and_group.yml
|
file: noauto_create_backup_user_and_group.yml
|
||||||
...
|
...
|
||||||
|
@ -1,28 +1,23 @@
|
|||||||
---
|
---
|
||||||
# In this Play an ssh key pair is created for login to the backup server and secure data transfer.
|
- name: Create SSH key (if neeeded) for {{ borg_user }}
|
||||||
# We do not want the possibly existing key to be used/distributed,
|
|
||||||
# so a backup-specific (backup/backup.pub) one is created.
|
|
||||||
- name: Create ssh-key (if neeeded) for {{ borgbackup_user }}
|
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Ensure directory exist
|
- name: Ensure directory exist
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ backup_user_info.home }}/.ssh/"
|
path: "{{ backup_user_info.home }}/.ssh/"
|
||||||
state: directory
|
state: directory
|
||||||
mode: "0700"
|
mode: "0700"
|
||||||
owner: "{{ borgbackup_user }}"
|
owner: "{{ borg_user }}"
|
||||||
group: "{{ borgbackup_group }}"
|
group: "{{ borg_group }}"
|
||||||
|
|
||||||
- name: Generate an OpenSSH keypair
|
- name: Generate an OpenSSH keypair
|
||||||
community.crypto.openssh_keypair:
|
community.crypto.openssh_keypair:
|
||||||
path: "{{ borg_ssh_key_file_path }}"
|
path: "{{ borg_ssh_key_file_path }}"
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
type: "{{ borg_ssh_key_type }}"
|
type: "{{ borg_ssh_key_type }}"
|
||||||
owner: "{{ borgbackup_user }}"
|
owner: "{{ borg_user }}"
|
||||||
group: "{{ borgbackup_group }}"
|
group: "{{ borg_group }}"
|
||||||
|
|
||||||
- name: Read ssh key
|
- name: Read SSH key
|
||||||
ansible.builtin.slurp:
|
ansible.builtin.slurp:
|
||||||
src: "{{ borg_ssh_key_file_path }}.pub"
|
src: "{{ borg_ssh_key_file_path }}.pub"
|
||||||
register: backup_local_ssh_key
|
register: backup_local_ssh_key
|
||||||
|
@ -10,5 +10,5 @@
|
|||||||
group: "{{ item.group }}"
|
group: "{{ item.group }}"
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
with_items:
|
with_items:
|
||||||
- { src: "docker.sh", dest: "/usr/local/bin/docker.sh", owner: "{{ borgbackup_user }}", group: "{{ borgbackup_group }}", mode: "0770" }
|
- { src: "docker.sh", dest: "/usr/local/bin/docker.sh", owner: "{{ borg_user }}", group: "{{ borg_group }}", mode: "0770" }
|
||||||
...
|
...
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
---
|
---
|
||||||
- name: Configure borgbackup
|
- name: Add Borgmatic config file
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Ensure /etc/borgmatic exists
|
- name: Ensure /etc/borgmatic exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/borgmatic
|
path: /etc/borgmatic
|
||||||
state: directory
|
state: directory
|
||||||
mode: "0700"
|
mode: "0700"
|
||||||
owner: "{{ borgbackup_user }}"
|
owner: "{{ borg_user }}"
|
||||||
group: "{{ borgbackup_group }}"
|
group: "{{ borg_group }}"
|
||||||
|
|
||||||
- name: Add Borgmatic configuration
|
- name: Add Borgmatic configuration
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: config.yaml.j2
|
src: config.yaml.j2
|
||||||
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
|
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
owner: "{{ borgbackup_user }}"
|
owner: "{{ borg_user }}"
|
||||||
group: "{{ borgbackup_group }}"
|
group: "{{ borg_group }}"
|
||||||
...
|
...
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
- name: Create borgbackup timer
|
- name: Create borgbackup timer
|
||||||
when:
|
when:
|
||||||
- borgmatic_timer is defined and borgmatic_timer | length > 0
|
- borgmatic_timer is defined and borgmatic_timer | length > 0
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Start timer install script
|
- name: Start timer install script
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
---
|
---
|
||||||
- name: Setup backup environment
|
- name: Setup backup environment
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
when:
|
when:
|
||||||
- backup_create_local_user is not defined or backup_create_local_user
|
- backup_create_local_user is not defined or backup_create_local_user
|
||||||
- borgbackup_user != "root"
|
- borg_user != "root"
|
||||||
block:
|
block:
|
||||||
- name: Add local backup group
|
- name: Add local backup group
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "{{ borgbackup_group }}"
|
name: "{{ borg_group }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Add local backup user
|
- name: Add local backup user
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ borgbackup_user }}"
|
name: "{{ borg_user }}"
|
||||||
shell: "/bin/bash"
|
shell: "/bin/bash"
|
||||||
groups: "{{ borgbackup_group }}"
|
groups: "{{ borg_group }}"
|
||||||
comment: "Backup User Account"
|
comment: "Backup User Account"
|
||||||
append: true
|
append: true
|
||||||
register: user_info
|
register: user_info
|
||||||
@ -28,9 +26,9 @@
|
|||||||
community.general.sudoers:
|
community.general.sudoers:
|
||||||
name: "backup"
|
name: "backup"
|
||||||
state: present
|
state: present
|
||||||
user: "{{ borgbackup_user }}"
|
user: "{{ borg_user }}"
|
||||||
nopassword: true
|
nopassword: true
|
||||||
commands:
|
commands:
|
||||||
- "/opt/borgmatic/bin/borg"
|
- "/opt/borgmatic/bin/borg"
|
||||||
- "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
- "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
||||||
...
|
...
|
||||||
|
@ -4,16 +4,14 @@
|
|||||||
name: "{{ borg_cron_package }}"
|
name: "{{ borg_cron_package }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Add cron-job for borgmatic
|
- name: Add Cron job for borgmatic
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Add cron job for create, check and prune
|
- name: Add cron job for create, check and prune
|
||||||
cron:
|
cron:
|
||||||
name: "{{ borgmatic_timer_cron_name }}"
|
name: "{{ borgmatic_timer_cron_name }}"
|
||||||
hour: "{{ borgmatic_timer_hour }}"
|
hour: "{{ borgmatic_timer_hour }}"
|
||||||
minute: "{{ borgmatic_timer_minute }}"
|
minute: "{{ borgmatic_timer_minute }}"
|
||||||
user: "{{ borgbackup_user }}"
|
user: "{{ borg_user }}"
|
||||||
cron_file: "{{ borgmatic_timer_cron_name }}"
|
cron_file: "{{ borgmatic_timer_cron_name }}"
|
||||||
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
||||||
|
|
||||||
@ -23,10 +21,8 @@
|
|||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Set PATH for borgmatic cron job.
|
- name: Set PATH for borgmatic cron job.
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
cron:
|
cron:
|
||||||
user: "{{ borgbackup_user }}"
|
user: "{{ borg_user }}"
|
||||||
cron_file: "{{ borgmatic_timer_cron_name }}"
|
cron_file: "{{ borgmatic_timer_cron_name }}"
|
||||||
name: PATH
|
name: PATH
|
||||||
env: yes
|
env: yes
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Create borgbackup timer
|
- name: Create borgbackup timer
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Copy systemd files
|
- name: Copy systemd files
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
@ -47,5 +45,5 @@
|
|||||||
- name: Show hints
|
- name: Show hints
|
||||||
when: "'backup_init_repo' not in ansible_run_tags"
|
when: "'backup_init_repo' not in ansible_run_tags"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Attention: Since the repo was not initialized automatically, the systemd service (borgmatic.service) and the timer (bborgmatic.timer) are not activated."
|
msg: "Attention: Since the repo was not initialized automatically, the systemd service (borgmatic.service) and the timer (borgmatic.timer) are not activated."
|
||||||
...
|
...
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Install borgbackup by distro
|
- name: Install borgbackup by distro
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Check if EPEL repo is enabled, if installation from distro is requested
|
- name: Check if EPEL repo is enabled, if installation from distro is requested
|
||||||
when: ansible_os_family == 'RedHat'
|
when: ansible_os_family == 'RedHat'
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Install Borg and Borgmatic via pip
|
- name: Install Borg and Borgmatic via pip
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
@ -32,8 +30,6 @@
|
|||||||
loop: "{{ borg_python_packages }}"
|
loop: "{{ borg_python_packages }}"
|
||||||
|
|
||||||
- name: Create links to Borgmatic and Borg binarys
|
- name: Create links to Borgmatic and Borg binarys
|
||||||
tags:
|
|
||||||
- install_backup
|
|
||||||
block:
|
block:
|
||||||
- name: Create borgmatic command in /usr/local/bin
|
- name: Create borgmatic command in /usr/local/bin
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@ -43,8 +39,8 @@
|
|||||||
borgmatic "$@"
|
borgmatic "$@"
|
||||||
dest: /usr/local/bin/borgmatic
|
dest: /usr/local/bin/borgmatic
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
owner: "{{ borgbackup_user }}"
|
owner: "{{ borg_user }}"
|
||||||
group: "{{ borgbackup_group }}"
|
group: "{{ borg_group }}"
|
||||||
|
|
||||||
- name: Create borg command in /usr/local/bin
|
- name: Create borg command in /usr/local/bin
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@ -54,8 +50,8 @@
|
|||||||
borg "$@"
|
borg "$@"
|
||||||
dest: /usr/local/bin/borg
|
dest: /usr/local/bin/borg
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
owner: "{{ borgbackup_user }}"
|
owner: "{{ borg_user }}"
|
||||||
group: "{{ borgbackup_group }}"
|
group: "{{ borg_group }}"
|
||||||
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -11,7 +11,7 @@ ConditionACPower=true
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
User={{ borgbackup_user }}
|
User={{ borg_user }}
|
||||||
ExecStart=/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}
|
ExecStart=/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}
|
||||||
|
|
||||||
# Source: https://projects.torsion.org/borgmatic-collective/borgmatic/raw/branch/master/sample/systemd/borgmatic.service
|
# Source: https://projects.torsion.org/borgmatic-collective/borgmatic/raw/branch/master/sample/systemd/borgmatic.service
|
||||||
|
Loading…
Reference in New Issue
Block a user