initial devcontainer setup
This commit is contained in:
commit
b9b7aa6a08
14 changed files with 411 additions and 0 deletions
33
.devcontainer/snap_db.sh
Executable file
33
.devcontainer/snap_db.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Ensure the .snapshots directory exists
|
||||
mkdir -p "$PROJECT_ROOT/.snapshots"
|
||||
|
||||
# Generate the base filename with timestamp
|
||||
base_filename="$PROJECT_ROOT/.snapshots/snapshot_$(date +%Y%m%d_%H%M%S)"
|
||||
|
||||
# Initialize an empty string for sanitized arguments
|
||||
sanitized_args=""
|
||||
|
||||
# Loop through all arguments
|
||||
for arg in "$@"; do
|
||||
# Sanitize the argument: remove spaces and special characters
|
||||
sanitized=$(echo "$arg" | tr -cd '[:alnum:]_-')
|
||||
sanitized_args="${sanitized_args}_${sanitized}"
|
||||
done
|
||||
|
||||
# Remove leading underscore if present
|
||||
sanitized_args=${sanitized_args#_}
|
||||
|
||||
# Create the final filename
|
||||
if [ -n "$sanitized_args" ]; then
|
||||
filename="${base_filename}_${sanitized_args}.sql"
|
||||
else
|
||||
filename="${base_filename}.sql"
|
||||
fi
|
||||
|
||||
# Run pg_dump and save to the generated filename
|
||||
pg_dump --no-tablespaces ${PGDATABASE} -f "$filename"
|
||||
|
||||
# Print the filename that was written
|
||||
echo "Snapshot saved to: $filename"
|
Loading…
Add table
Add a link
Reference in a new issue