Git initial commit
This commit is contained in:
commit
36ed650628
14 files changed
+364
No files matched your search
Executable
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- name: generate backup ssh user
|
||||
user:
|
||||
name: "{{ backup_owner }}"
|
||||
group: "{{ backup_group }}"
|
||||
comment: Backup user
|
||||
shell: /bin/sh
|
||||
|
||||
- name: Setup User ssh_key
|
||||
authorized_key:
|
||||
user: "{{ backup_owner }}"
|
||||
key: "{{ backup_owner_ssh_key }}"
|
||||
|
||||
- name: generate config lists
|
||||
template:
|
||||
src: backup/conf/{{ conf }}.list.j2
|
||||
dest: "{{ backup_conf }}/{{ conf }}.list"
|
||||
loop:
|
||||
- filedir
|
||||
- db
|
||||
- mail
|
||||
loop_control:
|
||||
loop_var: conf
|
||||
label: "{{ conf }}.list"
|
||||
|
||||
- name: setup backup script
|
||||
template:
|
||||
src: backup/backup_on_client.sh.j2
|
||||
dest: "{{ backup_folder }}/backup.sh"
|
||||
mode: 0740
|
||||
|
||||
- name: setup cronjob for client backup generation
|
||||
cron:
|
||||
name: "backup"
|
||||
weekday: "{{ backup_times_weekday }}"
|
||||
hour: "{{ backup_times_hour | join(',') }}"
|
||||
minute: "{{ backup_times_minute }}"
|
||||
job: "{{ backup_folder }}/backup.sh"
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
# Basics
|
||||
- name: install requirements for backup system
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: "{% if cloud_update | bool %}latest{% else %}present{% endif %}"
|
||||
install_recommends: yes
|
||||
pkg:
|
||||
- rsync
|
||||
|
||||
- name: setup storage folders for backup
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ dir.value.path }}"
|
||||
owner: "{{ backup_owner }}"
|
||||
group: "{{ backup_group }}"
|
||||
mode: "{{ backup_permission }}"
|
||||
with_dict: "{{ backup_storage }}"
|
||||
loop_control:
|
||||
loop_var: dir
|
||||
label: "{{ dir.key }}"
|
||||
|
||||
- name: setup conf folder
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ backup_folder }}/conf"
|
||||
|
||||
- name: setup client backup structure
|
||||
include_tasks: client.yml
|
||||
when: backup_client
|
||||
|
||||
- name: setup server backup structure
|
||||
include_tasks: server.yml
|
||||
when: not backup_client
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: analyse backup hours for pulling server
|
||||
set_fact:
|
||||
backup_times_server_hour: "{{ backup_times_server_hour | default([]) + [item + backup_hour_shift] }}"
|
||||
loop: "{{ backup_times_hour }}"
|
||||
|
||||
- name: generate backup user ssh key
|
||||
user:
|
||||
name: "{{ backup_owner }}"
|
||||
generate_ssh_key: yes
|
||||
ssh_key_type: rsa
|
||||
ssh_key_bits: 4096
|
||||
home: "{{ backup_folder }}"
|
||||
|
||||
- name: template main server backup pull script
|
||||
template:
|
||||
src: backup/backup_from_clients.sh.j2
|
||||
dest: "{{ backup_folder }}/pull-backup.sh"
|
||||
mode: 0740
|
||||
|
||||
- name: setup cronjob for server backup pull
|
||||
cron:
|
||||
name: "pull backups"
|
||||
weekday: "{{ backup_times_weekday }}"
|
||||
hour: "{{ backup_times_server_hour | join(',') }}"
|
||||
minute: "{{ backup_times_minute }}"
|
||||
job: "{{ backup_folder }}/pull-backup.sh"
|
||||
Reference in new issue
Block a user