Рубрика: Программирование
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
Когда надо обратиться с apache на nginx
docker-compose
nginx: image: nginx restart: always container_name: app-nginx volumes: - ./nginx.conf:/etc/nginx/nginx.conf - ./nginx/:/etc/nginx/conf.d/ - ./apache/data/:/data/ environment: TZ: "Europe/Moscow" ports: - "80:80" - "443:443" networks: - front - backend apache: build: ./apache container_name: app-apache restart: always volumes: - ./php.ini:/usr/local/etc/php/php.ini - ./apache/data/:/data/ links: - "nginx:test1.yandex.ru"
Когда нужно дать понять php что он работает по ssl
if ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) { $_SERVER['HTTPS'] = 'on'; $_SERVER['SERVER_PORT'] = 443; }
Steps to clear out the history of a git/github repository
-- Remove the history from rm -rf .git -- recreate the repos from the current content only git init git add . git commit -m "Initial commit" -- push to the github remote repos ensuring you overwrite history git remote add origin git@github.com:/ .git git push -u --force origin master
warning: CRLF will be replaced by LF in
error: warning: CRLF will be replaced by LF in style.scss. The file will have its original line endings in your working directory. solution: git config core.autocrlf true
Подсчет количества по дате
SELECT COUNT(id) AS count_id, DATE_FORMAT(`date`, '%Y %m %d %H') AS d, header, anons FROM cms_news GROUP BY d ORDER BY id
Creating ISO images from a folder in OSX
hdiutil makehybrid -o ~/Desktop/image.iso ~/path/to/folder/to/be/converted -iso -joliet
mysql trigger history table
Поддержка для триггеров включена, начиная с MySQL 5.0.2.
Когда нужно историчность данных
CREATE TABLE `user` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NULL DEFAULT NULL, `password` CHAR(32) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB AUTO_INCREMENT=0 ; CREATE TABLE `user_history` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `user_id` INT(11) NULL DEFAULT NULL, `name` VARCHAR(255) NULL DEFAULT NULL, `password` CHAR(32) NULL DEFAULT NULL, `date_changed` DATETIME NULL DEFAULT NULL, PRIMARY KEY (`id`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB AUTO_INCREMENT=0 ; CREATE DEFINER=`root`@`%` TRIGGER `history` BEFORE UPDATE ON `user` FOR EACH ROW BEGIN INSERT INTO user_history SELECT NULL, h.*, NOW() FROM user h WHERE id = OLD.id; END
Log cron
grep CRON /var/log/syslog