Entferne Sicherung NC und Mega/OneDrive (#23)
This commit is contained in:
parent
f5248e88d9
commit
90341fdb2b
25 changed files with 1 additions and 544 deletions
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- hosts: lxc-test.grote.lan
|
||||
- hosts: all
|
||||
become: yes
|
||||
gather_facts: false
|
||||
max_fail_percentage: 20%
|
||||
|
|
|
@ -16,5 +16,3 @@
|
|||
roles:
|
||||
- { role: mgrote.postfix-gmail, tags: "postfix-gmail" }
|
||||
- { role: mgrote.fileserver_smb, tags: "fileserver_smb" }
|
||||
- { role: mgrote.sicherung_nextcloud, tags: "nextcloud_sicherung", when: ansible_hostname == "fileserver2" }
|
||||
- { role: mgrote.sicherung_cloud, tags: "cloud", when: ansible_hostname == "fileserver2" }
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
## mgrote.sicherung_cloud
|
||||
|
||||
### Beschreibung
|
||||
Installiert und konfiguriert rclone.
|
||||
Benoetigt dafuer "stefangweichinger.rclone".
|
||||
|
||||
Legt einen Cronjob an.
|
||||
|
||||
Laedt regelmaessig alle Ordner vom NAS(fileserver2.grote.lan) direkt, also vom Host auf MEGA und OneDrive hoch.
|
||||
|
||||
### Funktioniert auf
|
||||
- [x] Ubuntu (>=18.04)
|
||||
|
||||
### Variablen + Defaults
|
||||
##### Minuten wann das Script ausgefuehrt werden soll
|
||||
rclone_cron_minutes: 30
|
||||
##### Stunden wann das Script ausgefuehrt werden soll
|
||||
rclone_cron_hours: 22
|
||||
##### Uploadgeschwindigkeitsbeschraenkung - Bandbreite in KBytes/s
|
||||
rclone_bandbreite: 500
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
rclone_bandbreite: "500"
|
||||
rclone_cron_minutes: "30"
|
||||
rclone_cron_hours: "22"
|
||||
rclone_pfad: "/usr/local/bin/rclone"
|
|
@ -1,13 +0,0 @@
|
|||
dependencies:
|
||||
- role: stefangweichinger.rclone
|
||||
galaxy_info:
|
||||
author: mgrote
|
||||
description: installs rclone and configures backup to gsuite
|
||||
min_ansible_version: 2.0
|
||||
license: GPLv3
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- system
|
|
@ -1,62 +0,0 @@
|
|||
- name: Ordner "/etc/sicherung_cloud" erstellen
|
||||
become: yes
|
||||
file:
|
||||
path: /etc/sicherung_cloud
|
||||
state: directory
|
||||
|
||||
- name: Kopiere rclone.conf
|
||||
become: yes
|
||||
template:
|
||||
src: rclone.conf
|
||||
dest: /etc/sicherung_cloud/rclone.conf
|
||||
force: no #sorgt dafuer fas die Datei nur kopiert wird wenn sie noch nicht existiert
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0700
|
||||
|
||||
- name: Kopiere rclone.sh
|
||||
become: yes
|
||||
template:
|
||||
src: rclone.sh
|
||||
dest: /usr/local/bin/sicherung_cloud.sh
|
||||
mode: a+x
|
||||
|
||||
- name: cronjob fuer rclone anlegen
|
||||
become: yes
|
||||
cron:
|
||||
name: rclone
|
||||
state: present
|
||||
job: "/usr/local/bin/sicherung_cloud.sh"
|
||||
minute: "{{ rclone_cron_minutes }}"
|
||||
hour: "{{ rclone_cron_hours }}"
|
||||
|
||||
- name: Create sicherung-cloud log
|
||||
become: true
|
||||
file:
|
||||
path: /var/log/sicherung_cloud.log
|
||||
state: touch
|
||||
mode: 0775
|
||||
access_time: preserve
|
||||
modification_time: preserve
|
||||
|
||||
- name: Add sicherung-cloud log to be Rotated
|
||||
become: true
|
||||
blockinfile:
|
||||
path: /etc/logrotate.d/sicherung-cloud
|
||||
state: present
|
||||
create: yes
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
block: |
|
||||
/var/log/sicherung_cloud.log {
|
||||
su root root
|
||||
create 0640 root root
|
||||
rotate 4
|
||||
weekly
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
dateext
|
||||
dateyesterday
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
[onedrive]
|
||||
type = onedrive
|
||||
token = {"access_token":"{{ sicherung_cloud_onedrive_token }}","expiry":"2020-04-22T15:36:26.3240594+02:00"}
|
||||
drive_id = 57b3bb1c1487f84e
|
||||
drive_type = personal
|
||||
|
||||
[onedrive-encrypt]
|
||||
type = crypt
|
||||
remote = onedrive:/rclone/encrypt
|
||||
filename_encryption = standard
|
||||
directory_name_encryption = false
|
||||
password = {{ sicherung_cloud_onedrive_password }}
|
||||
password2 = {{ sicherung_cloud_onedrive_password2 }}
|
||||
|
||||
[mega]
|
||||
type = mega
|
||||
user = {{ sicherung_cloud_mega_user }}
|
||||
pass = {{ sicherung_cloud_mega_pass }}
|
||||
|
||||
[mega-encrypt]
|
||||
type = crypt
|
||||
remote = mega:/
|
||||
filename_encryption = standard
|
||||
directory_name_encryption = false
|
||||
password = {{ sicherung_cloud_mega_password }}
|
||||
password2 = {{ sicherung_cloud_mega_password2 }}
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/bash
|
||||
#####################
|
||||
# https://forum.rclone.org/t/bash-script-cronjob-for-automating-rclone-sync/13526/2
|
||||
LOCKDIR=${HOME}/.cache
|
||||
# Get an exclusive lock or exit
|
||||
function exlock() {
|
||||
exec {lock_fd}>${LOCKDIR}/$(basename $0).lock
|
||||
flock -nx "$lock_fd"
|
||||
if [[ $? == 1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Cleanup lock file and exit
|
||||
function unlock() {
|
||||
rm "${LOCKDIR}/$(basename $0).lock"
|
||||
[[ -n $1 ]] && exit $1
|
||||
exit
|
||||
}
|
||||
|
||||
# ruft die function "exlock" auf, damit wird im lock verzeichnis die Datei "rclone.sh.lock" erstellt
|
||||
# Damit prueft ob das Script ob es schon laeuft
|
||||
exlock
|
||||
|
||||
dt=$( date +%Y_%m_%d__%H_%M_%S)
|
||||
echo "--------------------------------------------------"
|
||||
echo $(date)
|
||||
####### ONEDRIVE
|
||||
{{ rclone_pfad }} --config /etc/sicherung_cloud/rclone.conf -v sync --log-file="/var/log/sicherung_cloud.log" --transfers 4 --checkers 8 --retries 5 --low-level-retries 10 --delete-after "/shares/Backup/NextCloud/Dokumente" "onedrive-encrypt:/Dokumente" --backup-dir "onedrive-encrypt:/old/Dokumente/$dt"
|
||||
|
||||
{{ rclone_pfad }} --config /etc/sicherung_cloud/rclone.conf -v sync --log-file="/var/log/sicherung_cloud.log" --transfers 4 --checkers 8 --retries 5 --low-level-retries 10 --delete-after "/shares/Backup/NextCloud/Rest/KeepassDB" "onedrive-encrypt:/Rest/KeepassDB" --backup-dir "onedrive-encrypt:/old/Rest/$dt"
|
||||
|
||||
|
||||
|
||||
####### MEGA
|
||||
{{ rclone_pfad }} --config /etc/sicherung_cloud/rclone.conf -v sync --log-file="/var/log/sicherung_cloud.log" --transfers 4 --checkers 8 --retries 5 --low-level-retries 10 --delete-after "/shares/Backup/NextCloud/Dokumente" "mega-encrypt:/Dokumente"
|
||||
|
||||
{{ rclone_pfad }} --config /etc/sicherung_cloud/rclone.conf -v sync --log-file="/var/log/sicherung_cloud.log" --transfers 4 --checkers 8 --retries 5 --low-level-retries 10 --delete-after "/shares/Backup/NextCloud/Rest/KeepassDB" "mega-encrypt:/Rest/KeepassDB"
|
||||
|
||||
{{ rclone_pfad }} --config /etc/sicherung_cloud/rclone.conf cleanup "mega-encrypt:"
|
||||
|
||||
|
||||
|
||||
#Hiermit wird die Lockdatei geloescht
|
||||
unlock
|
|
@ -1,23 +0,0 @@
|
|||
## mgrote.sicherung_medien
|
||||
|
||||
### Beschreibung
|
||||
Installiert und konfiguriert youtube-dl mit allen Hilfsprogrammen(ffmpeg).
|
||||
|
||||
Benoetigt mit hedii.youtube-dl.
|
||||
|
||||
Die Konfigurationsdaten liegen unter /usr/local/bin/youtube-dl.
|
||||
Es wird ein Cronjob angelegt der taeglich das Script startet.
|
||||
|
||||
### Funktioniert auf
|
||||
- [x] Ubuntu (>=18.04)
|
||||
|
||||
### Variablen + Defaults
|
||||
#### hedii.youtube-dl
|
||||
##### Ob Updates durchgefuehrt werden sollen
|
||||
youtubedl_update: false
|
||||
#### mgrote.sicherung_medien
|
||||
##### Playlisten die gesichert werden sollen
|
||||
playlisten_youtube:
|
||||
- { url: 'https://www.youtube.com/playlist?list=PLPM-eyPokAWNhhDNO4YzC5cGRwuI2ykwE', titel: 'music'}
|
||||
playlisten_podcast:
|
||||
- { url: 'https://sternengeschichten.podigee.io/feed/aac', titel: 'Sternengeschichten'}
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
sicherung_medien_bitrate: 500K
|
||||
sicherung_medien_ziel_youtube: "/shares_videos/Youtube/"
|
||||
sicherung_medien_ziel_podcast: "/shares/Musik/Podcasts/"
|
||||
youtubedl_cron_minutes: "40"
|
||||
youtubedl_cron_hours: "21"
|
||||
youtubedl_cron_day: "/3"
|
|
@ -1,16 +0,0 @@
|
|||
dependencies:
|
||||
- role: hedii.youtube-dl
|
||||
vars:
|
||||
youtubedl_executable_path: "/usr/local/bin/youtube-dl"
|
||||
youtubedl_update: true
|
||||
galaxy_info:
|
||||
author: mgrote
|
||||
description: installs youtube-dl and configures youtube-backup
|
||||
min_ansible_version: 2.0
|
||||
license: GPLv3
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- system
|
|
@ -1,60 +0,0 @@
|
|||
- name: install ffmpeg
|
||||
become: yes
|
||||
apt:
|
||||
name: ffmpeg
|
||||
state: absent
|
||||
|
||||
- name: create /etc/sicherung_medien
|
||||
become: yes
|
||||
file:
|
||||
path: /etc/sicherung_medien
|
||||
state: absent
|
||||
|
||||
- name: create sicherung_medien_* log
|
||||
become: true
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- /var/log/sicherung_medien_youtube.log
|
||||
- /var/log/sicherung_medien_podcast.log
|
||||
|
||||
- name: copy conf-*.txt
|
||||
become: yes
|
||||
file:
|
||||
path: "/etc/sicherung_medien/{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- conf-youtube.txt
|
||||
- conf-podcast.txt
|
||||
|
||||
- name: copy ytdl-*.sh
|
||||
become: yes
|
||||
file:
|
||||
path: "/usr/local/bin/{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- ytdl-youtube.sh
|
||||
- ytdl-podcast.sh
|
||||
|
||||
- name: create cronjob sicherung_medien_*
|
||||
become: yes
|
||||
cron:
|
||||
name: sicherung_medien_{{ item }}
|
||||
state: absent
|
||||
job: "/usr/local/bin/{{ item }}"
|
||||
minute: "{{ youtubedl_cron_minutes }}"
|
||||
hour: "{{ youtubedl_cron_hours }}"
|
||||
day: "{{ youtubedl_cron_day }}"
|
||||
with_items:
|
||||
- ytdl-youtube.sh
|
||||
- ytdl-podcast.sh
|
||||
|
||||
- name: Add logs to logrotate
|
||||
become: true
|
||||
file:
|
||||
path: "/etc/logrotate.d/{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- sicherung_medien_youtube.log
|
||||
- sicherung_medien_podcast.log
|
|
@ -1,34 +0,0 @@
|
|||
#erzwinge ipv4
|
||||
--force-ipv4
|
||||
#bei fehlern weitermachen
|
||||
--ignore-errors
|
||||
#downloadrate begrenzen
|
||||
--limit-rate {{ sicherung_medien_bitrate }}
|
||||
#wartezeit zwischen downloads
|
||||
--sleep-interval 5
|
||||
#kein tls check
|
||||
--no-check-certificate
|
||||
#lese und schreibe archiv log
|
||||
--download-archive "{{ sicherung_medien_ziel_podcast }}/archive-podcast.log"
|
||||
#nehme nur gueltige dateinamenszeichen
|
||||
--restrict-filenames
|
||||
#ueberschreibe keine dateien
|
||||
--no-overwrites
|
||||
#ordner + dateinamen
|
||||
--output "{{ sicherung_medien_ziel_podcast }}%(playlist)s/%(title)s-%(id)s.%(ext)s"
|
||||
|
||||
# fuer linux
|
||||
--encoding utf-8
|
||||
|
||||
--embed-subs
|
||||
--add-metadata
|
||||
--write-info-json
|
||||
--write-description
|
||||
--write-annotations
|
||||
|
||||
#playlisten
|
||||
|
||||
{% for item in playlisten_podcast %}
|
||||
## {{item.titel}}
|
||||
{{item.url}}
|
||||
{% endfor %}
|
|
@ -1,36 +0,0 @@
|
|||
#erzwinge ipv4
|
||||
--force-ipv4
|
||||
#bei fehlern weitermachen
|
||||
--ignore-errors
|
||||
#downloadrate begrenzen
|
||||
--limit-rate {{ sicherung_medien_bitrate }}
|
||||
#wartezeit zwischen downloads
|
||||
--sleep-interval 30
|
||||
#kein tls check
|
||||
--no-check-certificate
|
||||
#lese und schreibe archiv log
|
||||
--download-archive "{{ sicherung_medien_ziel_youtube }}/archive-youtube.log"
|
||||
#nehme nur gueltige dateinamenszeichen
|
||||
--restrict-filenames
|
||||
#ueberschreibe keine dateien
|
||||
--no-overwrites
|
||||
#ordner + dateinamen
|
||||
--output "{{ sicherung_medien_ziel_youtube }}%(playlist)s/%(title)s-%(id)s.%(ext)s"
|
||||
#login
|
||||
--username {{ sicherung_medien_username }}
|
||||
--password {{ sicherung_medien_passwort }}
|
||||
# fuer linux
|
||||
--encoding utf-8
|
||||
|
||||
--embed-subs
|
||||
--add-metadata
|
||||
--write-info-json
|
||||
--write-description
|
||||
--write-annotations
|
||||
|
||||
#playlisten
|
||||
|
||||
{% for item in playlisten_youtube %}
|
||||
## {{item.titel}}
|
||||
{{item.url}}
|
||||
{% endfor %}
|
|
@ -1,31 +0,0 @@
|
|||
#!/bin/bash
|
||||
#####################
|
||||
# https://forum.rclone.org/t/bash-script-cronjob-for-automating-rclone-sync/13526/2
|
||||
LOCKDIR=${HOME}/.cache
|
||||
# Get an exclusive lock or exit
|
||||
function exlock() {
|
||||
exec {lock_fd}>${LOCKDIR}/$(basename $0).lock
|
||||
flock -nx "$lock_fd"
|
||||
if [[ $? == 1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Cleanup lock file and exit
|
||||
function unlock() {
|
||||
rm "${LOCKDIR}/$(basename $0).lock"
|
||||
[[ -n $1 ]] && exit $1
|
||||
exit
|
||||
}
|
||||
#####################
|
||||
# Damit prueft ob das Script ob es schon laeuft
|
||||
exlock
|
||||
#####################
|
||||
(
|
||||
echo "--------------------------------------------------"
|
||||
echo $(date)
|
||||
/usr/local/bin/youtube-dl --config-location "/etc/sicherung_medien/conf-podcast.txt"
|
||||
) >> /var/log/sicherung_medien_podcast.log 2>&1
|
||||
|
||||
#####################
|
||||
#Hiermit wird die Lockdatei geloescht
|
||||
unlock
|
|
@ -1,31 +0,0 @@
|
|||
#!/bin/bash
|
||||
#####################
|
||||
# https://forum.rclone.org/t/bash-script-cronjob-for-automating-rclone-sync/13526/2
|
||||
LOCKDIR=${HOME}/.cache
|
||||
# Get an exclusive lock or exit
|
||||
function exlock() {
|
||||
exec {lock_fd}>${LOCKDIR}/$(basename $0).lock
|
||||
flock -nx "$lock_fd"
|
||||
if [[ $? == 1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Cleanup lock file and exit
|
||||
function unlock() {
|
||||
rm "${LOCKDIR}/$(basename $0).lock"
|
||||
[[ -n $1 ]] && exit $1
|
||||
exit
|
||||
}
|
||||
#####################
|
||||
# Damit prueft ob das Script ob es schon laeuft
|
||||
exlock
|
||||
#####################
|
||||
(
|
||||
echo "--------------------------------------------------"
|
||||
echo $(date)
|
||||
/usr/local/bin/youtube-dl --config-location "/etc/sicherung_medien/conf-youtube.txt"
|
||||
) >> /var/log/sicherung_medien_youtube.log 2>&1
|
||||
|
||||
#####################
|
||||
#Hiermit wird die Lockdatei geloescht
|
||||
unlock
|
|
@ -1,22 +0,0 @@
|
|||
## mgrote.sicherung_nextcloud
|
||||
|
||||
### Beschreibung
|
||||
Installiert rclone fuer die Sicherung des NextClouds Servers: "mgrote.next-cloud.org".
|
||||
Es werden nur die Daten von "michaelgrote" gesichert.
|
||||
Die Daten werden per WebDAV kopiert.
|
||||
|
||||
### Funktioniert auf
|
||||
- [x] Ubuntu (>=18.04)
|
||||
- [ ] Debian
|
||||
|
||||
|
||||
### Variablen + Defaults
|
||||
Es sind keine "defaults" gesetzt.
|
||||
##### # Minuten wann das Script ausgefuehrt werden soll
|
||||
nextcloud_sicherung_cron_minutes: 30
|
||||
##### Stunden wann das Script ausgefuehrt werden soll
|
||||
nextcloud_sicherung_cron_hours: 18
|
||||
##### Pfad zu rclone (which)
|
||||
pfad_zu_rclone: "/usr/local/bin/rclone"
|
||||
##### Zielpfad
|
||||
sicherung_nextcloud_ziel: "/shares/backup/NextCloud"
|
|
@ -1,3 +0,0 @@
|
|||
---
|
||||
pfad_zu_rclone: "/usr/local/bin/rclone"
|
||||
sicherung_nextcloud_ziel: "/shares/backup/NextCloud"
|
|
@ -1,14 +0,0 @@
|
|||
dependencies:
|
||||
- role: stefangweichinger.rclone
|
||||
- role: mgrote.postfix-gmail
|
||||
galaxy_info:
|
||||
author: mgrote
|
||||
description: installs rclone and configures backup from nextcloud
|
||||
min_ansible_version: 2.0
|
||||
license: GPLv3
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- system
|
|
@ -1,63 +0,0 @@
|
|||
- name: Erstelle nextcloud
|
||||
become: yes
|
||||
file:
|
||||
path: /etc/nextcloud
|
||||
state: directory
|
||||
|
||||
- name: "Kopiere rclone.conf"
|
||||
become: yes
|
||||
template:
|
||||
src: rclone.conf
|
||||
dest: /etc/nextcloud/rclone.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0700
|
||||
|
||||
- name: "Kopiere nextcloud.sh"
|
||||
become: yes
|
||||
template:
|
||||
src: nextcloud.sh
|
||||
dest: /usr/local/bin/nextcloud-sicherung.sh
|
||||
mode: a+x
|
||||
|
||||
- name: cronjob fuer nextcloud-copy anlegen
|
||||
become: yes
|
||||
cron:
|
||||
name: nextcloud
|
||||
state: present
|
||||
job: "/usr/local/bin/nextcloud-sicherung.sh"
|
||||
minute: "{{ nextcloud_sicherung_cron_minutes }}"
|
||||
hour: "{{ nextcloud_sicherung_cron_hours }}"
|
||||
|
||||
- name: Create nextcloud-sicherung log
|
||||
become: true
|
||||
file:
|
||||
path: /var/log/nextcloud-sicherung.log
|
||||
state: touch
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
access_time: preserve
|
||||
modification_time: preserve
|
||||
|
||||
- name: Add nextcloud Log to be Rotated
|
||||
become: true
|
||||
blockinfile:
|
||||
path: /etc/logrotate.d/nextcloud-sicherung
|
||||
state: present
|
||||
create: yes
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
block: |
|
||||
/var/log/nextcloud-sicherung.log {
|
||||
su root root
|
||||
create 0640 root root
|
||||
rotate 4
|
||||
weekly
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
dateext
|
||||
dateyesterday
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# https://forum.rclone.org/t/bash-script-cronjob-for-automating-rclone-sync/13526/2
|
||||
LOCKDIR=${HOME}/.cache
|
||||
# Get an exclusive lock or exit
|
||||
function exlock() {
|
||||
exec {lock_fd}>${LOCKDIR}/$(basename $0).lock
|
||||
flock -nx "$lock_fd"
|
||||
if [[ $? == 1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Cleanup lock file and exit
|
||||
function unlock() {
|
||||
rm "${LOCKDIR}/$(basename $0).lock"
|
||||
[[ -n $1 ]] && exit $1
|
||||
exit
|
||||
}
|
||||
|
||||
exlock
|
||||
|
||||
{{ pfad_zu_rclone }} sync --config "/etc/nextcloud/rclone.conf" -v "nextcloud:/" "{{ sicherung_nextcloud_ziel }}" --log-file="/var/log/nextcloud-sicherung.log"
|
||||
|
||||
|
||||
unlock
|
|
@ -1,6 +0,0 @@
|
|||
[nextcloud]
|
||||
type = webdav
|
||||
url = https://mgrote.next-cloud.org/remote.php/dav/files/michaelgrote/
|
||||
vendor = nextcloud
|
||||
user = {{ sicherung_nextcloud_user }}
|
||||
pass = {{ sicherung_nextcloud_pass }}
|
Loading…
Reference in a new issue