Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : MacLustr Storage Node8# File : server/scripts/backup.sh9# Description : Daily consistent copy of the catalog (SQLite .backup) into10# ~/maclustr-storage/backups, 14 kept. The catalog holds the11# plaintext digests needed to decrypt: without it (and12# master.key) fragments are unreadable.13# Module : server14# Repository : https://git.spboucher.ai/maclustr-storage-ios15# Project Website : https://storage.spboucher.ai16# Created : 2026-12-0117# Last Modified : 2026-12-0118#19# Author : Simon-Pierre Boucher20# Position : Professor of Finance21# Institution : Université du Québec en Outaouais (UQO)22# Organization : SP Boucher23# Website : https://spboucher.ai24# Git : https://git.spboucher.ai25#26# Preferred Contact: admin@spboucher.ai27# Technical Contact: dev@spboucher.ai28# Security/Admin : admin@spboucher.ai29#30# Copyright (c) 202631# Simon-Pierre Boucher32# All rights reserved where applicable. This file is governed by the33# applicable project license, copyright notices and relevant law.34# Existing third-party rights and notices remain unaffected.35#36# License : None specified (no license file in this repository)37#38# Do not embed credentials, private keys, access tokens,39# certificates or confidential personal information.40#41# =============================================================================42# END OF SP BOUCHER SOURCE HEADER43# =============================================================================4445set -euo pipefail46export PATH="/opt/homebrew/bin:$PATH"47D="${MSC_DATA_DIR:-$HOME/maclustr-storage}"48mkdir -p "$D/backups"49out="$D/backups/coordinator-$(date +%Y%m%d-%H%M%S).db"50node -e 'const {DatabaseSync}=require("node:sqlite");const d=new DatabaseSync(process.argv[1]);d.exec(`VACUUM INTO \x27${process.argv[2]}\x27`);d.close()' "$D/coordinator.db" "$out"51gzip "$out"52ls -1t "$D/backups"/coordinator-*.db.gz | tail -n +15 | xargs -r rm -f53echo "backup $(basename "$out").gz ($(du -h "$out.gz" | cut -f1))"54