The blog about containerisation, virtual machines and useful shell snippets and findings

More secure mysqldump for docker container

In case you have warning message about insecure user and password usage from command line you can do following:

  1. use mysql_config_editor set login-path=local host=localhost user=db_user password executed in container via exec. That will create encrypted file.
  2. Specify --login-path=local instead of -u user and -p password in your backup script.

I have my backups via rsnapshot. This is something like TimeMachine for Mac with handy directory structure and without duplication.

And my backup script looks like this:

/usr/bin/ssh -i /mnt/HD/HD_a2/ffp/home/root/id_rsa_nexus.key -C core@myipaddress "docker exec itservice_db_1 mysqldump --login-path=local itservice_production" >
 mysqlbackup.sql

That will create mysql dump on your remote backup host without passing user and password in more secure way.

docker-compose exec db mysql_config_editor set --login_path=local --host=localhost --user=itservice --password

will ask password and save credentials in container.

Resources: http://stackoverflow.com/questions/20751352/suppress-warning-messages-using-mysql-from-within-terminal-but-password-written