feat: remove borg
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Install subliminal
|
||||
package:
|
||||
ansible.builtin.package:
|
||||
name: subliminal
|
||||
state: present
|
||||
|
||||
|
@@ -1,13 +0,0 @@
|
||||
---
|
||||
|
||||
borg_pass: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
62333166623737363731663766353330633335306532306366356536376232396664376430613434
|
||||
3966376539303238376461386262663066376338386537660a376365643761653463393539316232
|
||||
30653130383761653432306136333733653062356635643662616133366663646132383136313530
|
||||
3866343664393330610a623930316330626166343934623230313232626131386132393866373661
|
||||
6336
|
||||
borg_backup_path: ["/srv", "/home", "/etc"]
|
||||
borg_backup_excluded_path: ["/srv/NOBACKUP"]
|
||||
borg_backup_hour: 6
|
||||
borg_backup_minute: 0
|
@@ -1,30 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Create SSH key
|
||||
community.crypto.openssh_keypair:
|
||||
path: ~/.ssh/id_rsa
|
||||
|
||||
- name: Get SSH pub key
|
||||
ansible.builtin.command:
|
||||
cmd: cat ~/.ssh/id_rsa.pub
|
||||
changed_when: true
|
||||
register: ssh_keys
|
||||
|
||||
- name: Put backup script
|
||||
ansible.builtin.template:
|
||||
src: borgbackup.sh.j2
|
||||
dest: /usr/local/bin/borgbackup.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0750'
|
||||
|
||||
- name: Cron the backup script
|
||||
ansible.builtin.cron:
|
||||
name: "borg backup script"
|
||||
hour: "{{ borg_backup_hour }}"
|
||||
minute: "{{ borg_backup_minute }}"
|
||||
job: /usr/local/bin/borgbackup.sh
|
||||
|
||||
- name: Warns about borg init
|
||||
ansible.builtin.debug:
|
||||
msg: "Borg has been installed. Don’t forget to init with: \nborg init --encryption=repokey-blake2 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home"
|
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
## Variable
|
||||
export BORG_PASSPHRASE="{{ borg_pass }}"
|
||||
|
||||
## lancement de la sauvegarde
|
||||
borg create --exclude-caches {% for f in borg_backup_excluded_path %}-e {{ f }} {% endfor %} -s backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home::{now:%Y-%m-%d} {% for f in borg_backup_path %}{{ f }} {% endfor %}
|
||||
|
||||
|
||||
## récupération de l'espace
|
||||
borg prune -d 7 -w 4 -m 3 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home
|
||||
|
@@ -1,36 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Mount backup disk
|
||||
ansible.posix.mount:
|
||||
path: /backup
|
||||
src: LABEL=BACKUP
|
||||
fstype: xfs
|
||||
opts: noatime,nofail
|
||||
state: mounted
|
||||
|
||||
- name: Create backup user
|
||||
ansible.builtin.user:
|
||||
name: backup
|
||||
comment: Backup
|
||||
create_home: true
|
||||
home: /backup
|
||||
shell: /bin/bash
|
||||
system: true
|
||||
state: present
|
||||
|
||||
- name: Create directory for borg clients
|
||||
ansible.builtin.file:
|
||||
path: "/backup/repos/{{ hostvars[item]['ansible_fqdn'] }}"
|
||||
state: directory
|
||||
mode: '0750'
|
||||
owner: backup
|
||||
group: backup
|
||||
loop: "{{ groups['borg_client'] }}"
|
||||
|
||||
- name: Set authorized_keys for borg clients
|
||||
ansible.posix.authorized_key:
|
||||
user: backup
|
||||
key: "{{ hostvars[item]['ssh_keys']['stdout'] }}"
|
||||
key_options: "command=\"cd /backup/repos/{{ hostvars[item]['ansible_fqdn'] }}; borg serve --restrict-to-path /backup/repos/{{ hostvars[item]['ansible_fqdn'] }}\""
|
||||
state: present
|
||||
loop: "{{ groups['borg_client'] }}"
|
@@ -1,16 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Set borg fact
|
||||
ansible.builtin.set_fact:
|
||||
borgbackup: borg
|
||||
when: ansible_facts['distribution'] == "Archlinux"
|
||||
|
||||
- name: Set borgbackup fact
|
||||
ansible.builtin.set_fact:
|
||||
borgbackup: borgbackup
|
||||
when: ansible_facts['distribution'] == "Debian"
|
||||
|
||||
- name: Install borg package
|
||||
ansible.builtin.package:
|
||||
name: "{{ borgbackup }}"
|
||||
state: present
|
@@ -11,3 +11,4 @@ restic_backup_path: ["/srv", "/home", "/etc"]
|
||||
restic_backup_excluded_path: ["/srv/NOBACKUP"]
|
||||
restic_backup_hour: 6
|
||||
restic_backup_minute: 0
|
||||
restic_exe_group: "root"
|
||||
|
@@ -16,4 +16,4 @@
|
||||
path: "{{ restic_path }}"
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
group: "{{ restic_exe_group }}"
|
||||
|
@@ -12,7 +12,7 @@
|
||||
src: resticbackup.sh.j2
|
||||
dest: "{{ restic_script_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
group: "{{ restic_exe_group }}"
|
||||
mode: '0750'
|
||||
|
||||
- name: Cron backup script
|
||||
|
Reference in New Issue
Block a user