generated from ddev/ddev-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fetchdb (not installable yet) and custom provider samples
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |