#!/bin/bash set -e PGDATA="/data/postgres" BACKUP_DIR="/data/backups" DUMP_FILE="$BACKUP_DIR/n8n_backup.sql" PG_BIN="/usr/lib/postgresql/15/bin" restore_from_hf() { if [ -z "$HF_TOKEN" ] || [ -z "$HF_BACKUP_REPO" ]; then return fi python3 -c " from huggingface_hub import hf_hub_download try: hf_hub_download(repo_id='$HF_BACKUP_REPO', filename='n8n_backup.sql', repo_type='dataset', token='$HF_TOKEN', local_dir='$BACKUP_DIR') print('Backup downloaded from HF') except Exception as e: print(f'No backup found on HF: {e}') " } mkdir -p /data/postgres /data/backups /data/n8n /run/postgresql chown -R postgres:postgres /data/postgres /run/postgresql chmod 700 /data/postgres if [ ! -f "$PGDATA/PG_VERSION" ]; then su - postgres -c "$PG_BIN/initdb -D $PGDATA --encoding=UTF8 --locale=C" cat >> "$PGDATA/postgresql.conf" <