diff --git a/commands/host/fetchdb b/commands/host/fetchdb new file mode 100755 index 0000000..91d76d3 --- /dev/null +++ b/commands/host/fetchdb @@ -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 diff --git a/scripts/provider-samples/local.yaml b/scripts/provider-samples/local.yaml new file mode 100644 index 0000000..e3289a9 --- /dev/null +++ b/scripts/provider-samples/local.yaml @@ -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 diff --git a/scripts/provider-samples/tibus.yaml b/scripts/provider-samples/tibus.yaml new file mode 100755 index 0000000..676f858 --- /dev/null +++ b/scripts/provider-samples/tibus.yaml @@ -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 diff --git a/scripts/sample.env b/scripts/sample.env new file mode 100644 index 0000000..a2c92eb --- /dev/null +++ b/scripts/sample.env @@ -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