volumes
- #!/bin/bash
- VOLUMES=("postgres-iam-data" "postgres-sxs-data")
- FORCE=false
- while getopts "f" opt; do
- case $opt in
- f)
- FORCE=true
- ;;
- \?)
- echo "Invalid option: -$OPTARG" >&2
- exit 1
- ;;
- esac
- done
- for VOLUME in "${VOLUMES[@]}"; do
- if docker volume inspect "$VOLUME" &>/dev/null; then
- if [ "$FORCE" = true ]; then
- echo "Volume $VOLUME exists. Force flag detected. Removing and recreating..."
- docker volume rm "$VOLUME"
- docker volume create "$VOLUME"
- echo "Volume $VOLUME recreated successfully."
- else
- echo "Volume $VOLUME already exists. Skipping..."
- fi
- else
- echo "Volume $VOLUME does not exist. Creating..."
- docker volume create "$VOLUME"
- echo "Volume $VOLUME created successfully."
- fi
- done
- echo "Operation completed."
Pasted 2026-10-07 18:43:14
Short link:
Short link:
Recent Public Pastes