Skip to content

Instantly share code, notes, and snippets.

View ivanpetrushev's full-sized avatar

Ivan Petrushev ivanpetrushev

View GitHub Profile
@ivanpetrushev
ivanpetrushev / backup_all_mysql_containers.sh
Last active December 24, 2019 14:04
backup all mysql docker containers
#!/bin/bash
# to restore use:
# cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -uroot -p"$MYSQL_ROOT_PASSWORD" DATABASE
NOW=$(date +%Y-%m-%d)
WHERE=/backup/daily-mysql/
# list only running mysql containers
CONTAINERS=$(docker ps --format 'table {{.Image}} {{.Names}}' | grep mysql | awk '{print $2}')