SPB Git

Repository Public

offnode-backup.sh 3.1 KB 59 lines shellscript

1#!/bin/zsh2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : MacLustr SMS Gateway8# File             : deployment/offnode-backup.sh9# Module           : deployment10# Repository       : https://git.spboucher.ai/maclustr-sms11# Project Website  : https://sms.spboucher.ai12# Created          : 2026-11-3013# Last Modified    : 2026-11-3014#15# Author           : Simon-Pierre Boucher16# Position         : Professor of Finance17# Institution      : Université du Québec en Outaouais (UQO)18# Organization     : SP Boucher19# Website          : https://spboucher.ai20# Git              : https://git.spboucher.ai21#22# Preferred Contact: admin@spboucher.ai23# Technical Contact: dev@spboucher.ai24# Security/Admin   : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License          : None specified (no license file in this repository)33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# MacLustr SMS : copie hors nœud des sauvegardes chiffrées (M2U64 → M4M64b), lancée chaque jour par la passerelle M1M3242# (LaunchDaemon io.maclustr.maclustr-sms-offnode). Les archives sont déjà chiffrées ; les clés ne sont jamais copiées.43# La clé de la passerelle est chargée dans un agent jetable et transférée : aucune clé privée ne vit sur les nœuds.44set -uo pipefail45export PATH=/usr/bin:/bin:/usr/sbin:/sbin46LAN=$HOME/dispatch/lan.json47ip() { /usr/bin/python3 -c "import json,sys; print(json.load(open(\"$LAN\"))[\"ips\"][sys.argv[1]])" "$1"; }48SRC=$(ip M2U64); DST=$(ip M4M64b)49O=(-o ControlPath=none -o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new)50log() { print -r -- "$(date "+%Y-%m-%dT%H:%M:%S") $*"; }51eval "$(ssh-agent -s)" >/dev/null; trap "ssh-agent -k >/dev/null" EXIT52ssh-add -q $HOME/.ssh/id_ed25519 || { log "impossible de charger la clé de la passerelle"; exit 1; }53log "copie M2U64($SRC) -> M4M64b($DST)"54ssh $O $DST "mkdir -p -m 700 ~/backups-offnode/maclustr-sms" || { log "destination injoignable"; exit 1; }55ssh -A $O $SRC "rsync -a --delete-after -e \"ssh -o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new\" ~/backups/maclustr-sms/ ${DST}:backups-offnode/maclustr-sms/" || { log "rsync en échec"; exit 1; }56N=$(ssh $O $DST "ls ~/backups-offnode/maclustr-sms/db-*.dump.enc 2>/dev/null | wc -l" | tr -d " ")57LAST=$(ssh $O $DST "ls -1t ~/backups-offnode/maclustr-sms/db-*.dump.enc 2>/dev/null | head -1 | xargs -I{} basename {}")58log "terminé : $N archive(s) hors nœud, la plus récente $LAST"59
Files main
Menu

Theme