### Pros
+ Fast
+ Offline available
### Cons
- Manual update of dump
- Dump mostly very old
- Enlarges git project
----
#### `.ddev/providers/local.yaml`
```yaml[3-4|6-10|12-18]
# TYPO3 local data provider
db_import_command:
command: |
set -eu -o pipefail
gzip .data/db.sql.gz | ddev mysql db
service: host
files_import_command:
command: |
# set -x # You can enable bash debugging output by uncommenting
set -eu -o pipefail
mkdir -p ${DDEV_DOCROOT}/fileadmin
unzip /var/www/html/.data/files.zip -d ${DDEV_DOCROOT}/fileadmin
service: web
```
```bash
ddev pull local
```
---
## Webserver/SSH
Populate database and parts of fileadmin from the webserver directly via ssh & rsync
### Pros
+ One-Click update data & files
+ No dumps in git
+ No SSH Access
+ Access through GitLab
### Cons
- Initial CI Setup
- Setup Personal Access Token
----
### GitLab configuration
1. Enable "Package registry" for your project
- Settings > General > Visibility, project features, permissions
2. Set "Number of duplicate assets to keep" to 1
- Settings > Packages and registries
3. Define GitLab CI Task
1. Create dumps
2. Push to Package registry
----
#### `.gitlab-ci.yml`
```yaml[5-8|12-17|18-21]
dump-production-for-ddev:
image: $IMAGE_PHP
stage: .pre
when: manual
variables:
GIT_STRATEGY: none
GITLAB_RELEASE_VERSION: "1.0.0"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/site"
before_script:
- *setup_ssh
- apk add rsync --update
script:
- ssh -4 $SSH_USER@$SSH_SERVER "$PHP $SSH_REMOTE_PATH/vendor/bin/typo3cms database:export -c Default -e 'cache_*' -e '[bf]e_sessions' -e '[bf]e_users' -e 'index_*' -e 'sys_log' -e 'sys_lockedrecords' -e 'sys_file_processedfile' -e 'tx_webp_failed' -e 'tx_extensionmanager_*' -e 'tx_staticfilecache_queue' -e 'tx_solr_indexqueue_item' -e 'zzz_*' | gzip -9 -c" > ./db.sql.gz
- mkdir files
- rsync -avz --include="user" --include="user/***" --exclude="*" $SSH_USER@$SSH_SERVER:$SSH_REMOTE_PATH/public/fileadmin/ ./files/fileadmin
- rsync -avz --include="tx_junithcore" --include="tx_junithcore/***" --exclude="*" $SSH_USER@$SSH_SERVER:$SSH_REMOTE_PATH/public/uploads/ ./files/uploads
- zip -r files.zip files/*
# Make sure to set "Number of duplicate assets to keep" to 1 in your GitLab project settings -> Packages and registries
- |
curl --fail-with-body --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ./files.zip ${PACKAGE_REGISTRY_URL}/${GITLAB_RELEASE_VERSION}/files.zip
curl --fail-with-body --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ./db.sql.gz ${PACKAGE_REGISTRY_URL}/${GITLAB_RELEASE_VERSION}/db.sql.gz
.setup_ssh: &setup_ssh
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_PRIVATE_KEY" | ssh-add -
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\tControlMaster auto\n\tControlPath /tmp/ssh_mux_%h_%p_%r\n\tControlPersist 600\n\n" > ~/.ssh/config'
```
----
### Pesonal Access Token
1. Create a personal access token
- User > Preferences > Access tokens
- Expiration date: none
- Select scopes: read_api
2. Add PAT as environment variable to ddev globally
- GITLAB_COM_PAT
- GITLAB_MYCOMPANY_PAT
- ...
```bash
ddev config global --web-environment-add="GITLAB_COM_PAT=