Skip to content

Instantly share code, notes, and snippets.

@mahrous-amer
mahrous-amer / BigQueryDTSOwnershipTransfer.sh
Created August 5, 2025 06:30
Bash script to list BigQuery Data Transfer Service (DTS) jobs in specified Google Cloud project locations (us, asia-southeast1), check for a specific owner, and transfer ownership to a new user or service account using the bq command-line tool. Requires Google Cloud SDK and jq.
# Configuration variables
PROJECT_ID="project"
LOCATIONS=("us" "asia-southeast1")
CURRENT_OWNER="old"
NEW_OWNER="new"
# Ensure bq command-line tool is installed
if ! command -v bq &> /dev/null; then
echo "Error: bq command-line tool not found. Please install Google Cloud SDK."
exit 1
@mahrous-amer
mahrous-amer / backup_from_container.sh
Created January 6, 2026 13:33
A robust Bash script for backing up a SQL Server database from a Docker container to the host, with secure password handling, customisable options, optional compression, and enhanced error management.
#!/usr/bin/env bash
# SQL Server Docker Backup Script
set -euo pipefail # Exit on error, undefined var, pipe failure
# Default values
DEFAULT_CONTAINER_NAME="sqlserver"
DEFAULT_DATABASE_NAME="TestDb"
DEFAULT_SA_PASSWORD="YourStrong@Passw0rd"