Browse Source

borg-daily Skript

master 1.1
Olli Graf 3 years ago
parent
commit
d0d74e17ef
  1. 47
      bin/borg-daily
  2. 4
      hosts
  3. 9
      installsoft.yml
  4. 8
      roles/initpi/tasks/main.yml

47
bin/borg-daily

@ -0,0 +1,47 @@
#!/bin/bash
#########################################################################
# Copyright (C) 2020 Akito <the@akito.ooo> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
# https://borgbackup.readthedocs.io/en/stable/deployment/automated-local.html
# 0.2.0
PURPOSE="SYSTEM"
TARGET_HOST=""
LOCATION="/tank/borg/"
BORG_REPO="${HOSTNAME}"
TARGET="${TARGET_HOST}${LOCATION}${BORG_REPO}"
ARC_NAME="${HOSTNAME}+${USER}:$(date +"%Y%m%dT%H%M%S")"
BORG_COMMENT="Automated \"${PURPOSE}\" backup to repository \"${BORG_REPO}\" at \"${TARGET_HOST}${LOCATION}\" issued $(date +"%Y-%m-%dT%H:%M:%S")."
BORG_OPTS="--compression auto,lzma,9 --checkpoint-interval 900 --warning"
LOGFILE_LOCATION="/tmp"
LOGFILE="borg-${PURPOSE}_$(date +"%Y%m%dT%H%M%S").log"
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
borg create ${BORG_OPTS} \
--comment "${BORG_COMMENT}" \
--exclude /media \
--exclude /dev \
--exclude /run \
--exclude /tmp \
--exclude /sys \
--exclude /proc \
--exclude /mnt \
--exclude /tank \
--exclude /var/log \
"${TARGET}::${ARC_NAME}" \
/
# 2>> "${LOGFILE_LOCATION}/${LOGFILE}"
sync

4
hosts

@ -41,6 +41,8 @@ pis:
kirk:
brandine:
edna:
arnie:
bart:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_connection: ssh
@ -86,6 +88,8 @@ servers:
ollital.net:
ashkente.de:
olliberry.de:
mail.olli-cloud.de:
git.olli-cloud.de:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_connection: ssh

9
installsoft.yml

@ -0,0 +1,9 @@
---
- hosts: "{{ target }}"
gather_facts: false
remote_user: pi
roles:
- initpi
- log2ram
- disableswap

8
roles/initpi/tasks/main.yml

@ -3,6 +3,12 @@
path: ~/bin
state: directory
- name: create tank dir
become: true
file:
path: /tank
state: directory
- name: copy scripts
copy:
src: bin/{{ item }}
@ -34,6 +40,8 @@
# - yum
- dnsutils
- nfs-kernel-server
- vim
update_cache: yes
cache_valid_time: 86400
# autoremove: yes

Loading…
Cancel
Save