Skip to content

Instantly share code, notes, and snippets.

View CHIP0K's full-sized avatar
🏠
Working from home

Ihor CHIP0K

🏠
Working from home
View GitHub Profile
@CHIP0K
CHIP0K / zfs_snapshot_rotate.sh
Last active August 31, 2023 07:47
MySQL Multi-Source Replication
#!/usr/bin/env bash
source /etc/environment
SNAPSHOT_TIME=$(date +'%Y-%m-%d_%H-%M-%S')
ROTATE_HOURS="24"
LOGFILE=/var/log/zfs.log
ZPOOL_NAME="zp_mysql"
ZFS_DATASET="mysql/data"
@CHIP0K
CHIP0K / docker-cleanup.sh
Created May 21, 2023 13:17
To clean the environment in the docker
#!/bin/bash
# Do not run if removal already in progress.
pgrep "docker rm" && exit 0
# Remove Dead and Exited containers.
docker rm $(docker ps -a | grep "Dead\|Exited" | awk '{print $1}'); true
# It will fail to remove images currently in use.
docker rmi $(docker images -qf dangling=true); true
#!/bin/bash
source /etc/environment
DEST_DUMP_PATH="/opt/backups/mysql"
DAYS=3
DUMP_NAME="$(hostname)_$(date +"%d-%m-%Y_%s")" # Get date in dd-mm-yyyy_s format
S3CMD=$(which s3cmd)
AWS=$(which aws)
AWS_S3_BUCKET="mysql-backups"
@CHIP0K
CHIP0K / docker-compose.yml
Last active May 20, 2024 10:34
ELK stack
version: "3.9"
services:
setup:
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
restart: always
volumes:
- /data/certs:/usr/share/elasticsearch/config/certs
user: "0"
command: >
@CHIP0K
CHIP0K / mysql_to_json.sh
Last active March 21, 2023 09:06
shell_scripts
#!/usr/bin/env bash
##########
#
# If you have to convert a single table: set variable DB_TABLE=tablename
# If commenting DB_TABLE, this is a script to convert all tables in the database
#
##########
DB_DATABASE=dbname