Add Borg local sync system service and configuration
This commit is contained in:
95
config/ansible/tasks/servers/borg-local-sync.yml
Normal file
95
config/ansible/tasks/servers/borg-local-sync.yml
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
- name: Borg Local Sync Installation and Configuration
|
||||
block:
|
||||
- name: Set Borg backup facts
|
||||
ansible.builtin.set_fact:
|
||||
borg_passphrase: "{{ lookup('community.general.onepassword', 'Borg Backup', vault='Dotfiles', field='password') }}"
|
||||
borg_config_dir: "{{ ansible_env.HOME }}/.config/borg"
|
||||
borg_backup_dir: "/mnt/services"
|
||||
borg_repo_dir: "/mnt/object_storage/borg-repo"
|
||||
|
||||
- name: Create Borg local sync script
|
||||
template:
|
||||
src: borg-local-sync.sh.j2
|
||||
dest: /usr/local/bin/borg-local-sync.sh
|
||||
mode: "0755"
|
||||
owner: root
|
||||
group: root
|
||||
become: yes
|
||||
tags:
|
||||
- borg-local-sync
|
||||
|
||||
- name: Create Borg local sync systemd service
|
||||
template:
|
||||
src: borg-local-sync.service.j2
|
||||
dest: /etc/systemd/system/borg-local-sync.service
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
become: yes
|
||||
notify:
|
||||
- reload systemd
|
||||
tags:
|
||||
- borg-local-sync
|
||||
|
||||
- name: Create Borg local sync systemd timer
|
||||
template:
|
||||
src: borg-local-sync.timer.j2
|
||||
dest: /etc/systemd/system/borg-local-sync.timer
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
become: yes
|
||||
notify:
|
||||
- reload systemd
|
||||
- restart borg-local-sync-timer
|
||||
tags:
|
||||
- borg-local-sync
|
||||
|
||||
- name: Create log file for Borg local sync
|
||||
file:
|
||||
path: /var/log/borg-local-sync.log
|
||||
state: touch
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
become: yes
|
||||
tags:
|
||||
- borg-local-sync
|
||||
|
||||
- name: Enable and start Borg local sync timer
|
||||
systemd:
|
||||
name: borg-local-sync.timer
|
||||
enabled: yes
|
||||
state: started
|
||||
daemon_reload: yes
|
||||
become: yes
|
||||
tags:
|
||||
- borg-local-sync
|
||||
|
||||
- name: Add logrotate configuration for Borg local sync
|
||||
copy:
|
||||
content: |
|
||||
/var/log/borg-local-sync.log {
|
||||
daily
|
||||
rotate 30
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
create 644 root root
|
||||
}
|
||||
dest: /etc/logrotate.d/borg-local-sync
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
become: yes
|
||||
tags:
|
||||
- borg-local-sync
|
||||
- borg
|
||||
- backup
|
||||
|
||||
tags:
|
||||
- borg-local-sync
|
||||
- borg
|
||||
- backup
|
Reference in New Issue
Block a user