Fügt einen Mechanismus zur Nutzerverifizierung per E-Mail ein. Nach der Registrierung wird eine E-Mail mit einem zeitbasierten Verifizierungscode versandt. Der Nutzer muss diesen Code eingeben, um sein Konto zu aktivieren. Die Methode zur Erstellung des Codes ist zeitbasiert und ändert sich alle 15 Minuten.
47 lines
1.3 KiB
Bash
47 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
# === Configuration ===
|
|
BUCKET_NAME="ibc-db-backup"
|
|
ENDPOINT_URL="https://s3.eu-central-3.ionoscloud.com"
|
|
LOCAL_DOWNLOAD_DIR="./"
|
|
|
|
# === Use filename from argument if provided ===
|
|
if [ -n "$1" ]; then
|
|
LATEST_FILE="$1"
|
|
else
|
|
echo "📡 No filename provided, fetching latest..."
|
|
# === Get latest file from IONOS S3 bucket ===
|
|
LATEST_FILE=$(aws --profile ionos s3api list-objects-v2 \
|
|
--bucket "$BUCKET_NAME" \
|
|
--prefix "full-dump" \
|
|
--endpoint-url "$ENDPOINT_URL" \
|
|
--query 'Contents | sort_by(@, &LastModified) | [-1].Key' \
|
|
--output text)
|
|
|
|
# === Check if file was found ===
|
|
if [ "$LATEST_FILE" == "None" ] || [ -z "$LATEST_FILE" ]; then
|
|
echo "❌ No matching .sql.br file found."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
FILENAME=$(basename "$LATEST_FILE")
|
|
SQL_FILE="${FILENAME%.br}" # Remove .br suffix
|
|
|
|
echo "📥 Downloading $LATEST_FILE"
|
|
aws --profile ionos s3 cp "s3://$BUCKET_NAME/$LATEST_FILE" "$LOCAL_DOWNLOAD_DIR" \
|
|
--endpoint-url "$ENDPOINT_URL"
|
|
|
|
# === Decompress with Brotli ===
|
|
echo "🗜️ Decompressing $FILENAME -> $SQL_FILE"
|
|
brotli -d "$FILENAME"
|
|
|
|
# === Import into Postgres inside Docker ===
|
|
echo "🐘 Importing into PostgreSQL (database:main)"
|
|
docker exec -i "database" env PGPASSWORD="hHMP8cd^N3SnzGRR" \
|
|
psql -U "main" -d "main" < "$SQL_FILE"
|
|
|
|
echo "✅ Import complete."
|
|
|
|
# === Optional: Clean up
|
|
rm "$FILENAME" "$SQL_FILE" |