Open
Description
I want backup drupal database and ignore cache_*
tables to reduce the backup size.
I'm using EXTRA_BACKUP_OPTS
for add extra --ingore-tables with variable $db, but it does not works. The backup SQL file still including the cache_*
tables.
If I'm using --ignore-table=dsf.watchdog
without ${db} variable, it works.
I have also tried DB_NAME
variable, but still not works.
Here are 2 issues:
- How I can do this with dynamic db name?
- I want to dump only the data structure append to the backup SQL,How to do this? I'm tring the pre/post scripts but looks can't do this. Here is the example scripts FYI.
special_tables=$(mysql -h $DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASS -N -e "SELECT GROUP_CONCAT(table_name SEPARATOR ' ') FROM information_schema.tables WHERE table_schema='$DB_NAME' AND (table_name LIKE 'cache%' OR table_name = 'watchdog') AND table_type = 'BASE TABLE'")
mysqldump --single-transaction -h $DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASS $DB_NAME --no-data $special_tables >> $FILE_NAME
Here it the example docker-compose.yml
services:
db-backup-v4-mariadb:
image: tiredofit/db-backup:4.1.9
container_name: db-backup-v4-mariadb
restart: always
volumes:
- ./backups:/backup
environment:
- MODE=MANUAL
- MANUAL_RUN_FOREVER=FALSE
- CONTAINER_ENABLE_SCHEDULING=FALSE
- DEFAULT_FILESYSTEM_PATH=/backup
- DEFAULT_MYSQL_CLIENT=mariadb
- DEBUG_MODE=TRUE
- DEFAULT_LOG_LEVEL=debug
- EXTRA_BACKUP_OPTS=--ignore-table=$${db}.cache_advagg --ignore-table=$${db}.cache_bootstrap --ignore-table=$${db}.cache_config --ignore-table=$${db}.cache_container --ignore-table=$${db}.cache_data --ignore-table=$${db}.cache_default --ignore-table=$${db}.cache_discovery --ignore-table=$${db}.cache_dynamic_page_cache --ignore-table=$${db}.cache_entity --ignore-table=$${db}.cache_file_mdm --ignore-table=$${db}.cache_jsonapi_normalizations --ignore-table=$${db}.cache_menu --ignore-table=$${db}.cache_page --ignore-table=$${db}.cache_render --ignore-table=$${db}.cache_rest --ignore-table=$${db}.cache_schema_metatag_cache --ignore-table=$${db}.cache_toolbar --ignore-table=$${db}.cachetags --ignore-table=dsf.watchdog
- DB_TYPE=mysql
- DB_HOST=mariadb
- DB_USER=root
- DB_PASS=password
- ROTATE_OPTIONS=--daily=7 --weekly=4 --monthly=3 --prefer-recent
- DB_DUMP_BY_SCHEMA=true
#- SINGLE_DATABASE=true
#- RUN_ONCE=true
#- DB_DUMP_CRON="20, 2, * * *"
- DB_NAME=dsf
- DB_NAMES_EXCLUDE="information_schema performance_schema sys mysql"
- DB_DUMP_FREQ=1440
- DB_DUMP_BEGIN=1308
- DB_DUMP_DEBUG=true