Add duplicity
This commit is contained in:
parent
257b710ce3
commit
b17c4b2709
55
main.yml
55
main.yml
@ -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
|
24
roles/duplicity/files/backup.sh
Normal file
24
roles/duplicity/files/backup.sh
Normal 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"
|
9
roles/duplicity/tasks/account.yml
Normal file
9
roles/duplicity/tasks/account.yml
Normal 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
|
18
roles/duplicity/tasks/cron.yml
Normal file
18
roles/duplicity/tasks/cron.yml
Normal 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"
|
12
roles/duplicity/tasks/install.yml
Normal file
12
roles/duplicity/tasks/install.yml
Normal 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
|
6
roles/duplicity/tasks/main.yml
Normal file
6
roles/duplicity/tasks/main.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- import_tasks: account.yml
|
||||
|
||||
- import_tasks: install.yml
|
||||
|
||||
- import_tasks: cron.yml
|
Loading…
Reference in New Issue
Block a user