Skip to content

Commit

Permalink
Add fetchdb (not installable yet) and custom provider samples
Browse files Browse the repository at this point in the history
  • Loading branch information
bserem committed Nov 8, 2024
1 parent bb7488c commit 5653cb9
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
18 changes: 18 additions & 0 deletions commands/host/fetchdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

## Description: Get latest DB from live site
## Usage: fetchdb
## Example: "ddev fetchdb"

if [ -f "${DDEV_APPROOT}/.env" ]; then
set -a
source "${DDEV_APPROOT}/.env"
set +a
if [[ $DDEV_UPSTREAM_PROVIDER ]]; then
ddev pull $DDEV_UPSTREAM_PROVIDER --skip-files -y
else
echo "Couldn't identify provider, please use 'ddev pull' manually."
fi
else
echo "Couldn't identify provider, please use 'ddev pull' manually."
fi
23 changes: 23 additions & 0 deletions scripts/provider-samples/local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Griffith local file provider configuration.

# This will pull a database dump as provided (and named) by Griffith.
# The dump must be placed in the project root and follow the naming pattern:
# griffith-DD-MM-YYYY-TIME.mysql.bz2
#
# Examples:
# - griffith-06-09-2024-0700.mysql.bz2
# - griffith-04-11-2024-0700.mysql.bz2
#
# The script will identify and import the latest DB dump.

db_import_command:
command: |
set -eu -o pipefail
# set -x
# List of database dump files
files=(griffith-*.mysql.bz2)
# Find the latest dump file by sorting day-month-year format
latest_dump=$(printf "%s\n" "${files[@]}" | sort -t- -k4,4nr -k3,3nr -k2,2nr | head -n 1)
echo "The latest DB dump file is: $latest_dump"
ddev import-db --file=$latest_dump
service: host
21 changes: 21 additions & 0 deletions scripts/provider-samples/tibus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Example rsync provider configuration with ssh tunnels.
# Based on rsync provider.

# Note that while this is done in the web container (because rsync will always be there)
# it could also be done on the host, and then you wouldn't need the
# `ddev auth ssh`

environment_variables:
dburl: project.live:/path/to/db/dump/live.gz

auth_command:
command: |
set -eu -o pipefail
ssh-add -l >/dev/null || ( echo "Please 'ddev auth ssh' before running this command." && exit 1 )
db_pull_command:
command: |
# set -x # You can enable bash debugging output by uncommenting
set -eu -o pipefail
rsync -az -vvv -e "ssh -J ${AEGIR_USERNAME}@anrt.vpn" "${dburl}" /var/www/html/.ddev/.downloads/db.sql.gz
service: web
9 changes: 9 additions & 0 deletions scripts/sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change DDEV_UPSTREAM_PROVIDER to where `ddev pull` should look for a DB.
# It is used in `.ddev/commands/host/fetchdb`
# Example values:
# - platform
# - pantheon
# - local
# - rsync

# DDEV_UPSTREAM_PROVIDER=pantheon

0 comments on commit 5653cb9

Please sign in to comment.