Skip to content

Instantly share code, notes, and snippets.

@parsaeian
parsaeian / xtrabackup_full_increment_restore.sh
Created February 15, 2023 16:33 — forked from SQLadmin/xtrabackup_full_increment_restore.sh
Automate xtrabackup for FULL/Incremental and restore
#!/bin/bash
# This is my production backup script.
# https://sqlgossip.com
set -e
set -u
usage() {
echo "usage: $(basename $0) [option]"
echo "option=full: Perform Full Backup"
@parsaeian
parsaeian / cloudsend.sh
Created September 4, 2021 12:35 — forked from tavinus/cloudsend.sh
Send files to Nextcloud/Owncloud shared folder using curl
#!/usr/bin/env bash
############################################################
# MIGRATED TO REPOSITORY
# https://github.com/tavinus/cloudsend.sh
#
# This gist will NOT be updated anymore
############################################################
############################################################
@parsaeian
parsaeian / run-xtrabackup.sh
Created April 10, 2021 19:56 — forked from jmfederico/run-xtrabackup.sh
Script to create full/incremental backups with xtrabackup.
#!/bin/sh
TMPFILE="/tmp/xtrabackup-runner.$$.tmp"
USEROPTIONS="--user=${MYSQL_USER} --password=${MYSQL_PASSWORD} --host=${MYSQL_HOST}"
BACKDIR=/srv/mysql-bak
BASEBACKDIR=$BACKDIR/base
INCRBACKDIR=$BACKDIR/incr
FULLBACKUPCYCLE=604800 # Create a new full backup every X seconds
KEEP=1 # Number of additional backups cycles a backup should kept for.
START=`date +%s`
@parsaeian
parsaeian / nc-webserver.bash
Last active January 14, 2021 12:58
nc for test TCP requests
while true; do (echo -e 'HTTP/1.1 200 OK\r\n'; echo -e "\t$(date)\n") | nc -lp 8080; done
@parsaeian
parsaeian / backup-mysql.bash
Created November 26, 2020 10:05
Backup Mysql 8 with xtrabackup to remote server
xtrabackup --backup --compress --compress-threads=12 --parallel=12 --user=dbuser --password=dbpassword --stream=xbstream --target-dir=/path/to/mysql-data | ssh $remote_host "xbstream -x -p 12 -C /path/to/backup-dir"
@parsaeian
parsaeian / export-cluster.bash
Last active July 22, 2020 12:00
Generate yml files that will produce the existing kubernetes cluster.
for namespace in $(kubectl get -o name namespace)
do
ns=$(basename $namespace)
mkdir -p $ns
pushd $ns
for object_name in $(kubectl get -o=name pvc,configmap,serviceaccount,secret,ingress,service,deployment,statefulset,hpa,job,cronjob -n $ns)
do
mkdir -p $(dirname $object_name)
kubectl get -o=yaml --export $object_name -n $ns > $object_name.yaml
done
@parsaeian
parsaeian / change-container-dns.bash
Last active July 22, 2020 12:00
Single line command to change DNS resolver of docker containers
docker ps -a | awk '{print $NF}' | grep "container-name" | xargs -I'{}' docker exec {} sh -c 'echo "nameserver 8.8.8.8\nnameserver 1.1.1.1" | cat - /etc/resolv.conf | tee /etc/resolv.conf'

Keybase proof

I hereby claim:

  • I am parsaeian on github.
  • I am parsaeian (https://keybase.io/parsaeian) on keybase.
  • I have a public key whose fingerprint is 0825 62CF 99BA 3DB9 9526 EE3C 3393 304A F538 04F4

To claim this, I am signing this object: