mirror of
https://github.com/auricom/home-cluster.git
synced 2025-09-17 18:24:14 +02:00
feat: refactor cronjobs
This commit is contained in:
@@ -1 +1,7 @@
|
||||
use nix
|
||||
# Automatically sets up your devbox environment whenever you cd into this
|
||||
# directory via our direnv integration:
|
||||
|
||||
eval "$(devbox generate direnv --print-envrc)"
|
||||
|
||||
# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
|
||||
# for more details
|
||||
|
4
ansible/devbox.json
Normal file
4
ansible/devbox.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
|
||||
"packages": ["ansible@latest", "sshpass@latest"]
|
||||
}
|
117
ansible/devbox.lock
Normal file
117
ansible/devbox.lock
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"lockfile_version": "1",
|
||||
"packages": {
|
||||
"ansible@latest": {
|
||||
"last_modified": "2024-07-07T07:43:47Z",
|
||||
"resolved": "github:NixOS/nixpkgs/b60793b86201040d9dee019a05089a9150d08b5b#ansible",
|
||||
"source": "devbox-search",
|
||||
"version": "2.16.5",
|
||||
"systems": {
|
||||
"aarch64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/iib6zk86p80bnhp0yshswrlb4n7jwa27-python3.12-ansible-core-2.16.5",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "dist",
|
||||
"path": "/nix/store/9parf4f1ysgrxnv627b42q4i3g43y6xn-python3.12-ansible-core-2.16.5-dist"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/iib6zk86p80bnhp0yshswrlb4n7jwa27-python3.12-ansible-core-2.16.5"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/karakqxirk7fzqcqrk76q908gxrhqbdj-python3.12-ansible-core-2.16.5",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "dist",
|
||||
"path": "/nix/store/2yja52manchr4pl09xpz5xc7f0717n8g-python3.12-ansible-core-2.16.5-dist"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/karakqxirk7fzqcqrk76q908gxrhqbdj-python3.12-ansible-core-2.16.5"
|
||||
},
|
||||
"x86_64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/rda1qbxlmz6djni83pndqw9gxbbr85cg-python3.12-ansible-core-2.16.5",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "dist",
|
||||
"path": "/nix/store/mc7l7avn2za2rl6hv69jzs31ybi4m7dc-python3.12-ansible-core-2.16.5-dist"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/rda1qbxlmz6djni83pndqw9gxbbr85cg-python3.12-ansible-core-2.16.5"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/whq5kfbhx2ci4hrm6bl8z98fpi33mvkd-python3.12-ansible-core-2.16.5",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "dist",
|
||||
"path": "/nix/store/ih4c11ss3d96ljawj0ywyfyia70g8v2j-python3.12-ansible-core-2.16.5-dist"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/whq5kfbhx2ci4hrm6bl8z98fpi33mvkd-python3.12-ansible-core-2.16.5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sshpass@latest": {
|
||||
"last_modified": "2024-07-07T07:43:47Z",
|
||||
"resolved": "github:NixOS/nixpkgs/b60793b86201040d9dee019a05089a9150d08b5b#sshpass",
|
||||
"source": "devbox-search",
|
||||
"version": "1.10",
|
||||
"systems": {
|
||||
"aarch64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/48y6jzhm0w7y0hpb7447765w83jlhmgn-sshpass-1.10",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/48y6jzhm0w7y0hpb7447765w83jlhmgn-sshpass-1.10"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/cw68ibl6qw9d9f7m7p4al3fp4759xnkx-sshpass-1.10",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/cw68ibl6qw9d9f7m7p4al3fp4759xnkx-sshpass-1.10"
|
||||
},
|
||||
"x86_64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/x93zzyzkpzmr6n3iniyvihlglibln1rf-sshpass-1.10",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/x93zzyzkpzmr6n3iniyvihlglibln1rf-sshpass-1.10"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/6x512hbxjip723wvfsdf24h6ql3hyh99-sshpass-1.10",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/6x512hbxjip723wvfsdf24h6ql3hyh99-sshpass-1.10"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
---
|
||||
- name: backup | copy script
|
||||
ansible.builtin.template:
|
||||
src: backup.bash.j2
|
||||
dest: /storage/backup.bash
|
||||
mode: "0755"
|
||||
|
||||
- name: backup | crontab
|
||||
ansible.builtin.cron:
|
||||
name: daily backup
|
||||
minute: "14"
|
||||
hour: "4"
|
||||
job: /storage/backup.bash
|
@@ -1,8 +1,4 @@
|
||||
---
|
||||
- ansible.builtin.include_tasks: backup.yml
|
||||
tags:
|
||||
- backup
|
||||
|
||||
- ansible.builtin.include_tasks: nfs.yml
|
||||
tags:
|
||||
- nfs
|
||||
|
@@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Variables
|
||||
DATE=$(date +%Y%m%d%H%M)
|
||||
BACKUP_SRC="/storage/backup"
|
||||
BACKUP_DEST="homelab@storage.{{ internal_domain }}:/vol1/backups/servers/coreelec.{{ internal_domain }}/"
|
||||
|
||||
error_handler() {
|
||||
local error_line=$1
|
||||
local error_message=$2
|
||||
script_name=$(basename "$0")
|
||||
local script_name
|
||||
|
||||
echo "Error occurred in script '${script_name}' at line: ${error_line}"
|
||||
echo "Error message: ${error_message}"
|
||||
|
||||
curl -s \
|
||||
--form-string "token={{ pushover_api_token }}" \
|
||||
--form-string "user={{ pushover_user_key }}" \
|
||||
--form-string "message=coreelec.{{ internal_domain }}
|
||||
script: ${script_name}
|
||||
error_line: ${error_line}
|
||||
error_message: ${error_message}" \
|
||||
https://api.pushover.net/1/messages.json
|
||||
exit 1
|
||||
}
|
||||
|
||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||
|
||||
tar cvf "${BACKUP_SRC}/${DATE}.tar" \
|
||||
storage/.kodi storage/.config storage/.cache storage/.ssh \
|
||||
--exclude=storage/.kodi/userdata/Thumbnails
|
||||
|
||||
# Keep the last 5 backups on disk
|
||||
find "${BACKUP_SRC}/*.tar" -mtime +5 -type f -delete
|
||||
|
||||
rsync -avh "${BACKUP_SRC}/" "${BACKUP_DEST}" --delete
|
@@ -1,8 +0,0 @@
|
||||
{pkgs ? import <nixpkgs> {}}:
|
||||
with pkgs;
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
ansible
|
||||
sshpass
|
||||
];
|
||||
}
|
Reference in New Issue
Block a user