mirror of
https://github.com/luzifer-ansible/duplicity-backup.git
synced 2024-11-08 21:50:02 +00:00
63 lines
1.6 KiB
YAML
63 lines
1.6 KiB
YAML
---
|
|
|
|
- name: Install required apt packages
|
|
apt:
|
|
name:
|
|
- duplicity
|
|
- gnupg
|
|
- lftp
|
|
- python-pip
|
|
update_cache: yes
|
|
|
|
- name: Install required pip packages
|
|
pip:
|
|
name: "{{ item }}"
|
|
state: latest
|
|
with_items:
|
|
- boto
|
|
|
|
- name: Get current duplicity-backup version
|
|
shell: "/usr/local/bin/duplicity-backup --version || true"
|
|
check_mode: no
|
|
changed_when: no
|
|
register: duplicity_backup_version_cmd
|
|
|
|
- name: Install duplicity-backup wrapper
|
|
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
|
|
when: duplicity_backup_version not in duplicity_backup_version_cmd.stdout
|
|
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
|
|
|
|
- name: Deploy duplicity-s3 configuration
|
|
template:
|
|
src: duplicity-backup.yaml.j2
|
|
dest: /etc/duplicity-backup.yaml
|
|
|
|
- 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
|
|
|
|
- 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
|
|
|
|
- name: Ensure .config directory used by duplicity
|
|
file:
|
|
dest: /root/.config
|
|
state: directory
|
|
|
|
...
|