Skip to content

Instantly share code, notes, and snippets.

@fkaminski fkaminski/backup.sh
Last active Dec 19, 2018

Embed
What would you like to do?
Contao-Docker-Tutorial - backup.sh
#!/bin/bash
### Include
source vars.sh
echo -e $COL_START
echo -e " [STEP-1] Copy composer.* files from Container to Host $BACKUP_DIR directory"'\e[K'
echo -e $COL_STEP
eval 'docker cp '$CONTAINER_CONTAO':'$CONTAINER_WORKDIR'composer.json '$BACKUP_DIR''
eval 'docker cp '$CONTAINER_CONTAO':'$CONTAINER_WORKDIR'composer.lock '$BACKUP_DIR''
echo -e $COL_START
echo -e " [STEP-2] Copy Contao config files from Container to Host $BACKUP_DIR directory"'\e[K'
echo -e $COL_STEP
eval 'docker cp '$CONTAINER_CONTAO':'$CONTAINER_WORKDIR'app/config/parameters.yml '$BACKUP_DIR''
eval 'docker cp '$CONTAINER_CONTAO':'$CONTAINER_WORKDIR'system/config/localconfig.php '$BACKUP_DIR''
### Use docker exec without -t option to supress "mysqldump: [Warning] Using a password on the command line interface can be insecure." in sql file
### See https://github.com/docker-library/mysql/issues/132
echo -e $COL_START
echo -e " [STEP-3] Export DB Dump from Container to Host $BACKUP_DIR directory"'\e[K'
echo -e $COL_END
eval 'docker exec '$CONTAINER_DB' mysqldump -u '$GLOBAL_PASS_NAME' --password='$GLOBAL_PASS_NAME' '$GLOBAL_PASS_NAME' > '$BACKUP_DIR'/db_'$PROJECT_NAME'.sql'
eval 'docker exec '$CONTAINER_DB' mysqldump -u '$GLOBAL_PASS_NAME' --password='$GLOBAL_PASS_NAME' '$GLOBAL_PASS_NAME' | gzip > '$BACKUP_DIR'/db_'$PROJECT_NAME'.zip'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.