mirror of
https://github.com/roles-ansible/ansible_role_restic_archiver.git
synced 2024-08-16 10:09:49 +02:00
implement logrotate
This commit is contained in:
parent
3583b99f2e
commit
80baa38a8a
8 changed files with 73 additions and 63 deletions
|
@ -67,6 +67,9 @@ restic_archiver__umount_after_usage: false
|
|||
restic_archiver__package:
|
||||
- cron
|
||||
|
||||
restic_archiver__log_output: true
|
||||
restic_archiver__logrotate: true
|
||||
|
||||
# version check for this playbook (true is recomended)
|
||||
submodules_versioncheck: false
|
||||
```
|
||||
|
|
|
@ -46,5 +46,8 @@ restic_archiver__umount_after_usage: false
|
|||
restic_archiver__package:
|
||||
- cron
|
||||
|
||||
restic_archiver__log_output: true
|
||||
restic_archiver__logrotate: true
|
||||
|
||||
# version check for this playbook (true is recomended)
|
||||
submodules_versioncheck: false
|
||||
|
|
8
files/logrotate.conf
Normal file
8
files/logrotate.conf
Normal file
|
@ -0,0 +1,8 @@
|
|||
/var/log/restic/restic_archiver.log {
|
||||
rotate 182
|
||||
daily
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
}
|
28
tasks/cron.yml
Normal file
28
tasks/cron.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- name: install cron
|
||||
become: true
|
||||
package:
|
||||
name: "{{ restic_archiver__package }}"
|
||||
state: present
|
||||
|
||||
- name: setup cronjob for restic with logging
|
||||
become: true
|
||||
cron:
|
||||
name: "archive restic backup with ansible_role_restic_archiver >> /var/log/restic/restic_archiver.log"
|
||||
job: /opt/restic-backup.sh
|
||||
cron_file: /etc/crontab
|
||||
hour: "{{ restic_archiver__hour }}"
|
||||
minute: "{{ restic_archiver__minute }}"
|
||||
user: "{{ restic_archiver__owner }}"
|
||||
when: restic_archiver__log_output
|
||||
|
||||
- name: setup cronjob for restic without logging
|
||||
become: true
|
||||
cron:
|
||||
name: "archive restic backup with ansible_role_restic_archiver"
|
||||
job: /opt/restic-backup.sh
|
||||
cron_file: /etc/crontab
|
||||
hour: "{{ restic_archiver__hour }}"
|
||||
minute: "{{ restic_archiver__minute }}"
|
||||
user: "{{ restic_archiver__owner }}"
|
||||
when: not restic_archiver__log_output
|
27
tasks/logs.yml
Normal file
27
tasks/logs.yml
Normal file
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
- name: create /var/log/restic/
|
||||
become: true
|
||||
file:
|
||||
path: /var/log/restic
|
||||
state: directory
|
||||
recurse: true
|
||||
group: "{{ restic_archiver__owner }}"
|
||||
owner: "{{ restic_archiver__group }}"
|
||||
mode: 0750
|
||||
|
||||
- name: install logrotate
|
||||
become: true
|
||||
package:
|
||||
name: logrotate
|
||||
state: present
|
||||
when: restic_archiver__logrotate | bool
|
||||
|
||||
- name: create logrotate config
|
||||
become: true
|
||||
copy:
|
||||
src: files/logrotate.conf
|
||||
dest: /etc/logrotate.d/restic
|
||||
group: "{{ restic_archiver__owner }}"
|
||||
owner: "{{ restic_archiver__group }}"
|
||||
mode: 0644
|
||||
when: restic_archiver__logrotate | bool
|
|
@ -11,18 +11,7 @@
|
|||
mode: 0700
|
||||
become: true
|
||||
|
||||
- name: install cron
|
||||
become: true
|
||||
package:
|
||||
name: "{{ restic_archiver__package }}"
|
||||
state: present
|
||||
- include_tasks: logs.yml
|
||||
when: restic_archiver__log_output | bool
|
||||
|
||||
- name: setup cronjob for restic
|
||||
become: true
|
||||
cron:
|
||||
name: "archive restic backup with ansible_role_restic_archiver"
|
||||
job: /opt/restic-backup.sh
|
||||
cron_file: /etc/crontab
|
||||
hour: "{{ restic_archiver__hour }}"
|
||||
minute: "{{ restic_archiver__minute }}"
|
||||
user: "{{ restic_archiver__owner }}"
|
||||
- include_tasks: cron.yml
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
---
|
||||
#- name: Create backup credentials
|
||||
# template:
|
||||
# src: restic_access_Linux.j2
|
||||
# dest: '{{ restic_script_dir }}/access-{{ item.name }}.sh'
|
||||
# mode: '0700'
|
||||
# owner: '{{ restic_dir_owner }}'
|
||||
# group: '{{ restic_dir_group }}'
|
||||
# no_log: true
|
||||
# with_items: '{{ restic_archiver__backups }}'
|
||||
# when:
|
||||
# - item.name is defined
|
||||
# - item.src is defined or item.stdin is defined
|
||||
# - item.src is defined or item.stdin and item.stdin_cmd is defined
|
||||
# - item.repo in restic_repos
|
||||
#
|
||||
#- name: Create backup script
|
||||
# template:
|
||||
# src: restic_script_Linux.j2
|
||||
# dest: '{{ restic_script_dir }}/backup-{{ item.name }}.sh'
|
||||
# mode: '0700'
|
||||
# owner: '{{ restic_dir_owner }}'
|
||||
# group: '{{ restic_dir_group }}'
|
||||
# no_log: true
|
||||
# with_items: '{{ restic_archiver__backups }}'
|
||||
# when:
|
||||
# - item.name is defined
|
||||
## - item.src is defined or item.stdin is defined
|
||||
# - item.src is defined or item.stdin and item.stdin_cmd is defined
|
||||
# - item.repo in restic_repos
|
||||
#
|
||||
#- name: Setup CRON jobs
|
||||
# cron:
|
||||
# name: 'do1jlr.restic_archiver {{ item.name }}'
|
||||
## job: 'CRON=true {{ restic_script_dir }}/backup-{{ item.name }}.sh'
|
||||
# minute: '{{ item.schedule_minute | default("*") }}'
|
||||
# hour: '{{ item.schedule_hour | default("*") }}'
|
||||
# weekday: '{{ item.schedule_weekday | default("*") }}'
|
||||
# month: '{{ item.schedule_month | default("*") }}'
|
||||
# cron_file: '/etc/crontab'
|
||||
# state: present
|
||||
# become: true
|
||||
# no_log: true
|
||||
## with_items: '{{ restic_archiver__backups }}'
|
||||
# when:
|
||||
# - restic_create_cron
|
||||
# - item.name is defined
|
||||
# - item.scheduled | default(false)
|
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
playbook_version_number: 28 # should be over ninethousand
|
||||
playbook_version_number: 29 # should be over ninethousand
|
||||
playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'
|
||||
|
|
Loading…
Reference in a new issue