Add duplicity

This commit is contained in:
Przemek Grondek 2023-02-05 16:34:01 +01:00
parent 257b710ce3
commit b17c4b2709
6 changed files with 97 additions and 27 deletions

View File

@ -1,31 +1,32 @@
---
- hosts: prusa
roles:
- ssh
- octoprint
- ubuntu
- hosts: docker_cluster
roles:
- node_explorer
- ssh
- docker-cluster
- ubuntu
- hosts: raspberry
roles:
- i2c-clock
- hosts: router.lan
roles:
- router
- hosts: remote_server
roles:
- docker
#- hosts: prusa
# roles:
# - ssh
# - octoprint
# - ubuntu
#
#- hosts: docker_cluster
# roles:
# - node_explorer
# - ssh
# - docker-cluster
# - ubuntu
#
#- hosts: raspberry
# roles:
# - i2c-clock
#
#- hosts: router.lan
# roles:
# - router
#
#- hosts: remote_server
# roles:
# - docker
- hosts: uatu.lan
roles:
- ssh
- ubuntu
- docker
# - ssh
# - ubuntu
# - docker
- duplicity

View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
source /home/duplicity/email-settings.sh
MAX_TIME="3M"
FULL_BACKUP_EVERY="1M"
SOURCE="/mnt/MAIN"
DESTINATION="onedrive://duplicity/nas"
LOG="/home/duplicity/backup.log"
rm $LOG
duplicity remove-older-than $MAX_TIME $DESTINATION >> $LOG
duplicity --full-if-older-than $FULL_BACKUP_EVERY $SOURCE $DESTINATION >> $LOG
sendemail \
-f "$EMAIL_SENDER" \
-t "$EMAIL_RECEIPIENT" \
-u "Duplicity backup log" \
-message-file=$LOG \
-s "$EMAIL_SERVER" \
-xu "$EMAIL_USER" \
-xp "$EMAIL_PASSWORD" \
-o "tls=$EMAIL_TLS"

View File

@ -0,0 +1,9 @@
---
- name: create duplicity account
become: yes
user:
name: duplicity
comment: Duplicity account
system: yes
password_lock: yes
home: /home/duplicity

View File

@ -0,0 +1,18 @@
---
- name: copy configuration
become: yes
copy:
src: backup.sh
dest: /home/duplicity/backup.sh
mode: '0750'
owner: duplicity
group: duplicity
- name: Create cron job for autobackup
become: yes
ansible.builtin.cron:
user: duplicity
name: "Backup"
minute: "0"
hour: "3"
job: "/home/duplicity/backup.sh"

View File

@ -0,0 +1,12 @@
---
- become: yes
block:
- name: install needed packages
apt:
update_cache: yes
pkg:
- duplicity
- python3-requests-oauthlib
- sendemail
- libio-socket-ssl-perl
- libnet-ssleay-perl

View File

@ -0,0 +1,6 @@
---
- import_tasks: account.yml
- import_tasks: install.yml
- import_tasks: cron.yml