@@ -369,9 +369,18 @@ done
369
369
{ {- end } }
370
370
{ {- end } }
371
371
372
- { { if .Values.elasticsearch.enabled } }
373
- { { include " drupal.wait-for-elasticsearch-command" . } }
374
- { { end } }
372
+ { {- if .Values.elasticsearch.enabled } }
373
+ { {- include " drupal.wait-for-elasticsearch-command" . } }
374
+ { {- if and .Release.IsInstall .Values.referenceData.elasticsearch } }
375
+ if [[ -f /app/reference-data/elasticsearch.tar.gz || -f /app/reference-data/elasticsearch.tar.gz ]]; then
376
+ echo "Importing elasticsearch reference data"
377
+ mkdir /tmp/elasticsearch
378
+ tar -xzf /app/reference-data/elasticsearch.tar.gz -C /tmp/elasticsearch
379
+ multielasticdump --direction=load --input=/tmp/elasticsearch --output=http://${ ELASTICSEARCH_HOST} :9200/
380
+ echo "Elasticsearch reference data imported"
381
+ fi
382
+ { {- end } }
383
+ { {- end } }
375
384
376
385
{ { if .Release.IsInstall } }
377
386
{ { .Values.php.postinstall.command } }
395
404
{ {- define " drupal.extract-reference-data" -} }
396
405
set -e
397
406
if [[ "$(drush status --fields=bootstrap)" = *'Successful'* ]] ; then
407
+
398
408
echo "Dump reference database."
399
409
dump_dir=/tmp/reference-data-export/
400
410
mkdir "${ dump_dir} "
@@ -462,6 +472,15 @@ if [[ "$(drush status --fields=bootstrap)" = *'Successful'* ]] ; then
462
472
/app/reference-data/{{ $index }}
463
473
{{ end -}}
464
474
{{- end }}
475
+
476
+ {{- if .Values.referenceData.elasticsearch }}
477
+ echo "Creating reference data for elasticsearch"
478
+ mkdir /tmp/elasticsearch
479
+ multielasticdump --direction=dump --input=http://${ELASTICSEARCH_HOST}:9200/ --output=/tmp/elasticsearch
480
+ tar -czf /tmp/elasticsearch.tar.gz -C /tmp/elasticsearch .
481
+ cp /tmp/elasticsearch.tar.gz /app/reference-data
482
+ {{- end }}
483
+
465
484
else
466
485
echo "Drupal is not installed, skipping reference database dump."
467
486
fi
519
538
520
539
{{- define "drupal.backup-command" -}}
521
540
{{ include "drupal.backup-command.dump-database" . }}
541
+ {{- if and .Values.elasticsearch.enabled .Values.backup.elasticsearch }}
542
+ {{- include "drupal.backup-command.dump-elasticsearch" . }}
543
+ {{- end }}
522
544
{{ include "drupal.backup-command.archive-store-backup" . }}
523
545
{{- end }}
524
546
545
567
echo "Database backup complete."
546
568
{{- end }}
547
569
570
+ {{- define "drupal.backup-command.dump-elasticsearch" }}
571
+ set -e
572
+
573
+ if ! command -v multielasticdump &> /dev/null
574
+ then
575
+ echo "multielasticdump could not be found. Elasticsearch backup failed."
576
+ exit 1
577
+ fi
578
+
579
+ # Dump elasticsearch data
580
+ echo "Starting Elasticsearch backup."
581
+ mkdir /tmp/elasticsearch
582
+ multielasticdump --direction=dump --input=http://${ELASTICSEARCH_HOST}:9200/ --output=/tmp/elasticsearch
583
+ tar -czf /tmp/elasticsearch.tar.gz -C /tmp/elasticsearch .
584
+
585
+ echo "Elasticsearch backup complete."
586
+ {{- end }}
587
+
548
588
{{- define "drupal.backup-command.archive-store-backup" -}}
549
589
550
590
# Compress the database dump and copy it into the backup folder.
554
594
555
595
# Create a folder for the backup
556
596
mkdir -p $BACKUP_LOCATION
597
+
598
+ {{- if .Values.elasticsearch.enabled }}
599
+ # Copy the elasticsearch dump into the backup folder.
600
+ cp /tmp/elasticsearch.tar.gz $BACKUP_LOCATION/
601
+ {{- end }}
602
+
603
+ # Copy the database dump into the backup folder.
557
604
cp /tmp/db.sql.gz $BACKUP_LOCATION/db.sql.gz
558
605
559
606
{{- if not .Values.backup.skipFiles }}
0 commit comments