first commit

This commit is contained in:
olli 2022-07-10 10:49:09 +02:00
commit 25d3792faa
2 changed files with 67 additions and 0 deletions

0
README.md Normal file
View File

67
backup.yml Normal file
View File

@ -0,0 +1,67 @@
---
- name: Backups
hosts: all
tasks:
- name: Install Packages
apt:
name:
- rsync
update_cache: no
install_recommends: no
- name: Create checks dir /usr/local/sbin/backup.d
ansible.builtin.file:
path: /usr/local/sbin/backup.d
owner: root
group: root
state: directory
mode: '0700'
- name: /usr/local/sbin/backup.sh
blockinfile:
path: /usr/local/sbin/backup.sh
mode: "0500"
owner: root
group: root
create: yes
marker: "# {mark} ANSIBLE MANAGED BLOCK"
block: |
. /etc/bash/gaboshlib.include
g_lockfile
g_nice
g_all-to-syslog
g_echo_ok "Starting $0"
set -o pipefail
BACKUPDIR=/home/backup
mkdir -p ${BACKUPDIR}
chmod 700 ${BACKUPDIR}
chown root. ${BACKUPDIR}
find /usr/local/sbin/backup.d -name "*.backup" -type f | sort | while read backup
do
g_echo "Running: $backup"
. "$backup"
done
g_echo "Backup-Skript beendet"
backup: yes
validate: /bin/bash -n %s
notify:
- name: /usr/local/sbin/backup.sh shebang
lineinfile:
path: /usr/local/sbin/backup.sh
insertbefore: BOF
line: "#!/bin/bash"
- name: /etc/cron.d/backup_local
blockinfile:
path: /etc/cron.d/backup_local
create: yes
mode: 0644
owner: root
group: root
marker: "# {mark} ANSIBLE MANAGED BLOCK"
block: |
5 0 * * * root /usr/local/sbin/backup.sh
backup: yes