1
1
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2025-01-18 08:06:16 +01:00
infrastructure/roles/borg_client/tasks/main.yml
Sven-Hendrik Haase cd6178e04d
Remove borg-restore.pl
The perl script is currently breaking and there's not really an advantage to keeping it around.
We've never used it.
2020-12-25 15:41:43 +01:00

68 lines
2.5 KiB
YAML

---
- name: install borg and tools
pacman: name=borg state=present
- name: check if borg repository already exists
command: borg list {{ item['host'] }}/{{ item['dir'] }}
environment:
BORG_RELOCATED_REPO_ACCESS_IS_OK: "yes"
register: borg_list
ignore_errors: True
loop: "{{ backup_hosts }}"
changed_when: borg_list.stdout | length > 0
- name: init borg repository
command: borg init -e keyfile {{ item['host'] }}/{{ item['dir'] }}
when: borg_list is failed
environment:
BORG_PASSPHRASE: ""
ignore_errors: True # This can sometimes fail if a backup is in progress :/
loop: "{{ backup_hosts }}"
- name: install convenience scripts
template: src=borg.j2 dest=/usr/local/bin/borg{{ item['suffix'] }} owner=root group=root mode=0755
loop: "{{ backup_hosts }}"
- name: install borg backup scripts
template: src=borg-backup.sh.j2 dest=/usr/local/bin/borg-backup{{ item['suffix'] }}.sh owner=root group=root mode=0755
loop: "{{ backup_hosts }}"
- name: install postgres backup script
template: src=backup-postgres.sh.j2 dest=/usr/local/bin/backup-postgres.sh owner=root group=root mode=0755
when: postgres_backup_dir is defined
- name: check whether postgres user exists
command: getent passwd postgres
register: check_postgres_user
ignore_errors: True
changed_when: check_postgres_user.stdout | length > 0
- name: make postgres backup directory
file: path={{ postgres_backup_dir }} owner=root group=root mode=0755 state=directory
when: check_postgres_user is succeeded and postgres_backup_dir is defined
- name: install mysql backup script
template: src=backup-mysql.sh.j2 dest=/usr/local/bin/backup-mysql.sh owner=root group=root mode=0755
when: mysql_backup_dir is defined
- name: install mysql backup config
template: src=backup-my.cnf.j2 dest={{ mysql_backup_defaults }} owner=root group=root mode=0644
when: mysql_backup_defaults is defined
- name: create mysql backup directory
file: path={{ mysql_backup_dir }} state=directory owner=root group=root mode=0755
when: mysql_backup_dir is defined
- name: install gitlab backup script
template: src=backup-gitlab.sh.j2 dest=/usr/local/bin/backup-gitlab.sh owner=root group=root mode=0755
when: inventory_hostname == "gitlab.archlinux.org"
- name: install systemd timer and service for backup
template: src={{ item }}.j2 dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
with_items:
- borg-backup.timer
- borg-backup.service
- name: activate systemd timers for backup
systemd: name=borg-backup.timer enabled=yes state=started daemon-reload=yes