2017-12-25 12:20:50 +00:00
|
|
|
---
|
2018-01-27 10:17:52 +00:00
|
|
|
|
2017-12-25 12:20:50 +00:00
|
|
|
- name: Install required apt packages
|
|
|
|
apt:
|
2018-12-27 13:07:00 +00:00
|
|
|
name:
|
|
|
|
- duplicity
|
|
|
|
- gnupg
|
|
|
|
- lftp
|
|
|
|
- python-pip
|
2017-12-25 12:20:50 +00:00
|
|
|
update_cache: yes
|
2021-10-06 22:42:45 +00:00
|
|
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version != '20.04'
|
2021-10-06 22:40:16 +00:00
|
|
|
|
|
|
|
- name: Install required apt packages
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- duplicity
|
|
|
|
- gnupg
|
|
|
|
- lftp
|
|
|
|
- python3-pip
|
|
|
|
update_cache: yes
|
2021-10-06 22:46:13 +00:00
|
|
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
|
2017-12-25 12:20:50 +00:00
|
|
|
|
2018-12-27 13:13:42 +00:00
|
|
|
- name: Install required pip package
|
2017-12-25 12:20:50 +00:00
|
|
|
pip:
|
2018-12-27 13:13:42 +00:00
|
|
|
name: boto
|
2017-12-25 12:20:50 +00:00
|
|
|
state: latest
|
|
|
|
|
|
|
|
- name: Get current duplicity-backup version
|
|
|
|
shell: "/usr/local/bin/duplicity-backup --version || true"
|
|
|
|
check_mode: no
|
2018-03-27 09:12:22 +00:00
|
|
|
changed_when: no
|
2017-12-25 12:20:50 +00:00
|
|
|
register: duplicity_backup_version_cmd
|
|
|
|
|
|
|
|
- name: Install duplicity-backup wrapper
|
2018-10-08 20:48:50 +00:00
|
|
|
unarchive:
|
|
|
|
remote_src: true
|
|
|
|
src: "https://github.com/Luzifer/duplicity-backup/releases/download/{{ duplicity_backup_version }}/duplicity-backup_linux_amd64.tar.gz"
|
|
|
|
dest: /usr/local/bin
|
2017-12-25 12:20:50 +00:00
|
|
|
when: duplicity_backup_version not in duplicity_backup_version_cmd.stdout
|
2018-10-08 20:48:50 +00:00
|
|
|
register: duplicity_backup_unarchive
|
|
|
|
|
|
|
|
- name: Move new duplicity-backup version in place
|
|
|
|
command: mv /usr/local/bin/duplicity-backup_linux_amd64 /usr/local/bin/duplicity-backup
|
|
|
|
when: duplicity_backup_unarchive.changed
|
2017-12-25 12:20:50 +00:00
|
|
|
|
|
|
|
- name: Deploy duplicity-s3 configuration
|
|
|
|
template:
|
|
|
|
src: duplicity-backup.yaml.j2
|
|
|
|
dest: /etc/duplicity-backup.yaml
|
|
|
|
|
|
|
|
- name: Add cronjob to clean logs
|
|
|
|
cron:
|
|
|
|
name: Cleanup logs
|
|
|
|
special_time: daily
|
|
|
|
job: /usr/bin/find /var/log/duplicity -type f -mtime +14 -delete
|
|
|
|
cron_file: duplicity
|
|
|
|
user: root
|
2018-01-27 10:17:52 +00:00
|
|
|
|
2020-08-17 19:31:59 +00:00
|
|
|
- name: Set up cron for backups
|
|
|
|
cron:
|
|
|
|
name: Duplicity Backup
|
|
|
|
special_time: hourly
|
|
|
|
job: /usr/bin/ionice -c3 /usr/bin/nice -n19 /usr/local/bin/duplicity-backup -f /etc/duplicity-backup.yaml backup
|
|
|
|
user: root
|
|
|
|
cron_file: duplicity
|
|
|
|
|
2018-01-27 10:17:52 +00:00
|
|
|
- name: Ensure .config directory used by duplicity
|
|
|
|
file:
|
|
|
|
dest: /root/.config
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
...
|