docker backup mysql DB

My

docker exec app-mysql /usr/bin/mysqldump -u bitrix --password=tA32KVQ bitrix | gzip -9 > backup.sql.gz

Other


# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql

# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE

script


#!/bin/bash

DATA=`date +"%Y-%m-%d_%H-%M"`
PATHB=/mnt/backups

# Бэкапим дампом
docker exec container_name /usr/bin/mysqldump -u root --password=rootpass db_name > "$PATHB"/"$DATA"-db_name.sql
# Жмем
/bin/gzip "$PATHB"/"$DATA"-db_name.sql
# Чистим, удаляя файлы старше 10-ти дней
/usr/bin/find "$PATHB" -type f -mtime +10 -exec rm -rf {} \;




rsync для забора с другого ПК

/usr/bin/rsync -av -e "ssh -p 17222 -i /root/.ssh/id_rsa" rsyncuser@162.111.178.155:/mnt/backups/* /backups/mysql

Backup a MySQL local or remote database
Command to backup a local or remote MySQL database using Docker:

$ docker run -it mysql /usr/bin/mysqldump -h [MYSQL_HOST] -u [MYSQL_USER] --password=[MYSQL_PASSWORD] [MYSQL_DATABASE] > backup.sql

Command to backup a local or remote MySQL database using Docker with compression (using gzip):

$ docker run -it mysql /usr/bin/mysqldump -h [MYSQL_HOST] -u [MYSQL_USER] --password=[MYSQL_PASSWORD] [MYSQL_DATABASE] | gzip -9 > backup.sql.gz

Backup a containerized MySQL database
Command to backup a containerized MySQL database creating a compressed file using Docker and gzip:

$ docker exec [MYSQL_CONTAINER] /usr/bin/mysqldump -u [MYSQL_USER] --password=[MYSQL_PASSWORD] [MYSQL_DATABASE] | gzip -9 > backup.sql.gz

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

Можно использовать следующие HTML-теги и атрибуты: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>