Instantly share code, notes, and snippets.

View gist:83db353f82c7637a46f3b040a4aa70f5
#!/bin/bash
# This will create a full db dump and store it to s3 bucket my-db-backup-bucket in folder full-db-backup
# You can modify all variables as you wish
# Here we are making dump to /data/database-backup/ make sure that the directory is there.
# Here we're not keeping dumps locally.
echo "Enter DB name: "
read db
echo "removing current backups from /data/database-backup/"
View AWS AMI deletion Python code
# Automated AMI and Snapshot Deletion
#
# @author Robert Kozora <bobby@kozora.me> [I made some changes]
#
# This script will search for all instances having a tag with "Backup" or "backup"
# on it. As soon as we have the instances list, we loop through each instance
# and reference the AMIs of that instances which has backup tag as "filter_date_fmt" variable value.
# We check that the latest daily backup
# succeeded then we store every image that's reached its DeleteOn tag's date for
# deletion. We then loop through the AMIs, deregister them and remove all the
View AWS AMI creation Python code
# Automated AMI Backups
#
# @author Robert Kozora <bobby@kozora.me> [I made some changes.]
#
# This script will search for all instances from all region and
# as soon as we have the instances list, we loop through each instance
# and create an AMI of it. Also, it will look for a "Retention" tag key which
# will be used as a retention policy number in days. If there is no tag with
# that name, it will use a 7 days default value for each AMI.
#
View gist:fef83b5949057187c1723597247155b6
#!/bin/bash
#Author : Arunlal A
#Website: https://www.crybit.com
echo -n "Enter databse user name: "
read THEUSER
skill -9 -u $THEUSER ; for i in `mysqladmin processlist | grep $THEUSER | awk '{print $2}'` ; do mysqladmin kill $i ; done ; echo "$THEUSER has been killed!"
View gist:7a5f697d3f71f243372b6526fccc810a
#!/bin/bash
#Author : Arunlal A
#Website: https://www.crybit.com
echo "Staring database backup process..."
for db in `echo 'show databases;' |mysql |grep -Ev "Database|information_schema|performance_schema"`; do mysqldump $db | gzip > /backup/$db.sql.gz ;done
echo "Done! Check /backup/ directory for your SQL files."
View gist:8c6cbae2266dc03a5d600700b0d2d6f5
#!/bin/sh
echo "This script is useful for only commonly using CMSs like WP, Joomla, Drupal, Magento, Drupal etc with known configuration location. If nothing listing and you are getting db conntction error check configuration manually.. Thanks by Arunlal"
echo "" > details.txt
echo "Please enter the cPanel username: "
read username
grep -irl ${username}_ /home/$username/*{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php 2>/dev/null grep -v -E "mail|error_log|sql|html|var">> ${username}confs.txt
var=`cat ${username}confs.txt`
if [ -n "$var" ]; then
for i in `cat ${username}confs.txt`; do echo $i >> details.txt; grep -E "DB_USER|user|username|DB_PASSWORD|secret|password" $i |grep -v -E "cookies|generate"