Update backup_client role for OpenBSD
This commit is contained in:
parent
64b5c031ee
commit
ca080e8611
|
@ -14,8 +14,9 @@ backup_client_folders_to_backup: ""
|
||||||
# Folder to deploy backup client scripts
|
# Folder to deploy backup client scripts
|
||||||
backup_client_scripts_folder: "/usr/local/sbin"
|
backup_client_scripts_folder: "/usr/local/sbin"
|
||||||
|
|
||||||
# Backup client user and home directory
|
# Backup client user, group and home directory
|
||||||
backup_client_user: "root"
|
backup_client_user: "root"
|
||||||
|
client_backup_group: "root"
|
||||||
backup_client_user_home: "/root"
|
backup_client_user_home: "/root"
|
||||||
|
|
||||||
# Crontask backup client scheduling
|
# Crontask backup client scheduling
|
||||||
|
@ -31,3 +32,9 @@ backup_client_mail_target: "root"
|
||||||
|
|
||||||
# Compression parameters
|
# Compression parameters
|
||||||
backup_client_compression_param: "lzma,9"
|
backup_client_compression_param: "lzma,9"
|
||||||
|
|
||||||
|
# Shell to use in script
|
||||||
|
backup_client_shell: /bin/bash
|
||||||
|
|
||||||
|
# Bin Borgbackup
|
||||||
|
backup_client_borgbackup_bin: /usr/bin/borg
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
package:
|
package:
|
||||||
name: "{{ cron_package }}"
|
name: "{{ cron_package }}"
|
||||||
state: present
|
state: present
|
||||||
when: backup_client_folders_to_backup != ""
|
when: backup_client_folders_to_backup != "" and ansible_os_family != 'OpenBSD'
|
||||||
notify: restart cron
|
notify: restart cron
|
||||||
|
|
||||||
- name: BorgBackup installed
|
- name: BorgBackup installed
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
src: backup.sh.j2
|
src: backup.sh.j2
|
||||||
dest: "{{ backup_client_scripts_folder }}/backup.sh"
|
dest: "{{ backup_client_scripts_folder }}/backup.sh"
|
||||||
owner: "{{ backup_client_user }}"
|
owner: "{{ backup_client_user }}"
|
||||||
group: "{{ backup_client_user }}"
|
group: "{{ backup_client_group }}"
|
||||||
mode: '0740'
|
mode: '0740'
|
||||||
when: backup_client_folders_to_backup != ""
|
when: backup_client_folders_to_backup != ""
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!{{ backup_client_shell }}
|
||||||
{% for backup_serv in groups['backup_server'] %}
|
{% for backup_serv in groups['backup_server'] %}
|
||||||
|
|
||||||
# Check if {{ backup_serv }} is a known host
|
# Check if {{ backup_serv }} is a known host
|
||||||
|
@ -7,15 +7,15 @@ if [ ! $? -eq 0 ]; then
|
||||||
ssh-keygen -F {{ backup_serv }} || ssh-keyscan {{ backup_serv }} >>~/.ssh/known_hosts
|
ssh-keygen -F {{ backup_serv }} || ssh-keyscan {{ backup_serv }} >>~/.ssh/known_hosts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
borg list backup-$(hostname -s)@{{ backup_serv }}:{{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s) &>/dev/null
|
{{ backup_client_borgbackup_bin }} list backup-$(hostname -s)@{{ backup_serv }}:{{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s) &>/dev/null
|
||||||
|
|
||||||
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
||||||
then
|
then
|
||||||
ssh backup-$(hostname -s)@{{ backup_serv }} mkdir -p {{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s) -m 0700
|
ssh backup-$(hostname -s)@{{ backup_serv }} mkdir -p {{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s) -m 0700
|
||||||
export BORG_PASSPHRASE=""
|
export BORG_PASSPHRASE=""
|
||||||
borg init --encryption=repokey backup-$(hostname -s)@{{ backup_serv }}:{{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s)
|
{{ backup_client_borgbackup_bin }} init --encryption=repokey backup-$(hostname -s)@{{ backup_serv }}:{{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
borg prune -v backup-$(hostname -s)@{{ backup_serv }}:{{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s) --keep-daily=7 --keep-weekly=4 --keep-monthly=1
|
{{ backup_client_borgbackup_bin }} prune -v backup-$(hostname -s)@{{ backup_serv }}:{{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s) --keep-daily=7 --keep-weekly=4 --keep-monthly=1
|
||||||
borg create --info --stats --compression {{ backup_client_compression_param }} backup-$(hostname -s)@{{ backup_serv }}:{{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s)::$(date +%F) $(find {{ backup_client_folders_to_backup }} -maxdepth 1 -type d | grep -Ev '^/$|^/tmp|^/lost\+found|^/run|^/proc|^/dev|^/sys' | tr '\n' ' ')
|
{{ backup_client_borgbackup_bin }} create --info --stats --compression {{ backup_client_compression_param }} backup-$(hostname -s)@{{ backup_serv }}:{{ hostvars[backup_serv]['backup_folder'] }}/$(hostname -s)::$(date +%F) $(find {{ backup_client_folders_to_backup }} -maxdepth 1 -type d | grep -Ev '^/$|^/tmp|^/lost\+found|^/run|^/proc|^/dev|^/sys' | tr '\n' ' ')
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -2,3 +2,7 @@
|
||||||
cron_service_name: cron
|
cron_service_name: cron
|
||||||
cron_package: cron
|
cron_package: cron
|
||||||
aliases_config_file: /etc/aliases
|
aliases_config_file: /etc/aliases
|
||||||
|
backup_client_user: root
|
||||||
|
backup_client_group: root
|
||||||
|
backup_client_shell: /bin/bash
|
||||||
|
backup_client_borgbackup_bin: /usr/bin/borg
|
||||||
|
|
|
@ -2,3 +2,7 @@
|
||||||
cron_service_name: cronie
|
cron_service_name: cronie
|
||||||
cron_package: cronie
|
cron_package: cronie
|
||||||
aliases_config_file: /etc/mail/aliases
|
aliases_config_file: /etc/mail/aliases
|
||||||
|
backup_client_user: root
|
||||||
|
backup_client_group: root
|
||||||
|
backup_client_shell: /bin/bash
|
||||||
|
backup_client_borgbackup_bin: /usr/bin/borg
|
||||||
|
|
8
roles/backup_client/vars/OpenBSD.yml
Normal file
8
roles/backup_client/vars/OpenBSD.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
cron_service_name: cron
|
||||||
|
cron_package: cron
|
||||||
|
aliases_config_file: /etc/mail/aliases
|
||||||
|
backup_client_user: root
|
||||||
|
backup_client_group: wheel
|
||||||
|
backup_client_shell: /bin/ksh
|
||||||
|
backup_client_borgbackup_bin: /usr/local/bin/borg
|
|
@ -2,3 +2,7 @@
|
||||||
cron_service_name: crond
|
cron_service_name: crond
|
||||||
cron_package: cronie
|
cron_package: cronie
|
||||||
aliases_config_file: /etc/aliases
|
aliases_config_file: /etc/aliases
|
||||||
|
backup_client_user: root
|
||||||
|
backup_client_group: root
|
||||||
|
backup_client_shell: /bin/bash
|
||||||
|
backup_client_borgbackup_bin: /usr/bin/borg
|
||||||
|
|
Loading…
Reference in a new issue