ncantu 937646cc45 Daily backup to git cron, backup/restore scripts, docs
**Motivations:**
- Export Signet and mining wallet backups to git with only 2 versions kept
- Document and add backup/restore scripts for signet and mining wallet

**Correctifs:**
- Backup-to-git uses SSH URL for passwordless cron; copy timestamped files only; prune to 2 versions; remove *-latest from backup repo

**Evolutions:**
- data/backup-to-git-cron.sh: daily export to git.4nkweb.com/4nk/backup
- save-signet-datadir-backup.sh, restore-signet-from-backup.sh, export-mining-wallet.sh, import-mining-wallet.sh
- features/backup-to-git-daily-cron.md, docs/MAINTENANCE.md backup section
- .gitignore: data/backup-to-git.log

**Pages affectées:**
- .gitignore, data/backup-to-git-cron.sh, docs/MAINTENANCE.md, features/backup-to-git-daily-cron.md
- save-signet-datadir-backup.sh, restore-signet-from-backup.sh, export-mining-wallet.sh, import-mining-wallet.sh
- Plus autres fichiers modifiés ou non suivis déjà présents dans le working tree
2026-02-04 03:07:57 +01:00

27 lines
1.5 KiB
Bash

#!/bin/bash
NBITS=${NBITS:-"1e0377ae"} #minimum difficulty in signet
WALLET=${WALLET:-"custom_signet"} # Wallet name for descriptor wallet
while true; do
ADDR=${MINETO:-$(bitcoin-cli -rpcwallet=$WALLET getnewaddress)}
if [[ -f "${BITCOIN_DIR}/BLOCKPRODUCTIONDELAY.txt" ]]; then
BLOCKPRODUCTIONDELAY_OVERRIDE=$(cat ~/.bitcoin/BLOCKPRODUCTIONDELAY.txt)
echo "Delay OVERRIDE before next block" $BLOCKPRODUCTIONDELAY_OVERRIDE "seconds."
sleep $BLOCKPRODUCTIONDELAY_OVERRIDE
else
BLOCKPRODUCTIONDELAY=${BLOCKPRODUCTIONDELAY:="0"}
if [[ BLOCKPRODUCTIONDELAY -gt 0 ]]; then
echo "Delay before next block" $BLOCKPRODUCTIONDELAY "seconds."
sleep $BLOCKPRODUCTIONDELAY
fi
fi
echo "Mine To:" $ADDR
# PRIVKEY should be available from .env via run.sh environment
# The miner will automatically use PRIVKEY from environment for descriptorprocesspsbt
# Export PRIVKEY to ensure it's available to the miner process
export PRIVKEY=${PRIVKEY:-$(cat ~/.bitcoin/PRIVKEY.txt 2>/dev/null || echo "")}
# Get block template and pipe it to miner
# Use bitcoin-cli with -datadir from BITCOIN_DIR (container env) but without -rpcwallet for miner (descriptorprocesspsbt is node RPC, not wallet RPC)
bitcoin-cli -rpcwallet=$WALLET getblocktemplate '{"rules": ["segwit", "signet"]}' | \
miner --cli="bitcoin-cli -datadir=${BITCOIN_DIR:-/root/.bitcoin}" generate --grind-cmd="bitcoin-util grind" --address=$ADDR --nbits=$NBITS --set-block-time=$(date +%s)
done