Skip to content

Instantly share code, notes, and snippets.

@ledger123
ledger123 / pgx.rst
Created July 17, 2016 10:25 — forked from runekaagaard/pgx.rst
Bash scripts for extracting individual databases from a sql file dumped using pg_dumpall

Postgresql Xtra commands

  • pgx_list_dbs: Lists the names of databases in an .sql file dumped using pg_dumpall.
  • pgx_extract_db: Extracts a single database from a sql file dumped with pg_dumpall and outputs its content to stdout.

Installation

@ledger123
ledger123 / create-mysql.bash
Created November 26, 2018 16:20 — forked from askz/create-mysql.bash
Simple bash script to create mysql db, user with generated password
#!/bin/bash
# The script will fail at the first error encountered
set -e
PASS=`pwgen -s 40 1`
mysql -uroot <<MYSQL_SCRIPT
CREATE DATABASE $1;
CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';
@ledger123
ledger123 / wp.sh
Created December 7, 2018 16:54 — forked from FeChagas/wp.sh
#!/bin/bash -e
clear
echo "============================================"
echo "Instalador de Wordpress"
echo "============================================"
echo "Host do Banco de dados: "
read -e dbhost
echo "Nome do Banco de dados: "
read -e dbname
echo "Usúario do Banco de dados: "
@ledger123
ledger123 / backup_mysqldb.sh
Last active October 2, 2019 02:51 — forked from skarllot/backup_mysqldb.sh
Bash script to backup all mysql databases thru mysqldump
#!/bin/bash
# Destiny folder where backups are stored
DEST=/tmp/bacula/server01
CURRDATE=$(date +"%F")
# Hostname where MySQL is running
HOSTNAME="srv-mysql"
# User name to make backup
USER="root"
@ledger123
ledger123 / mysql_backup.sh
Created April 7, 2019 02:39 — forked from chill117/mysql_backup.sh
Bash script to perform backups on one or more MySQL databases.
#!/bin/bash
#
# Use this script to perform backups of one or more MySQL databases.
#
# Databases that you wish to be backed up by this script. You can have any number of databases specified; encapsilate each database name in single quotes and separate each database name by a space.
#
# Example:
# databases=( '__DATABASE_1__' '__DATABASE_2__' )
@ledger123
ledger123 / webmon.sh
Created December 8, 2020 03:00 — forked from starsinmypockets/webmon.sh
Website monitor
#! /bin/bash
##
# Quick and dirty website monitor
#
# add to cron:
# */5 * * * * $HOME/webmon.sh >> $HOME/logs/user/cron.log 2>&1
##
if curl -s http://website.org | grep -q "Page title";
@ledger123
ledger123 / monitor.sh
Created December 8, 2020 03:02 — forked from chrisdlangton/monitor.sh
site monitor
#!/usr/bin/env bash
# script to check website status (online/ofline)
while read site
do
if wget -p "$site" -O /dev/null &>/dev/null; then
echo "$site is up"
else
# action to do if website offline
echo "[$(date +%d-%m-%Y:%H:%M:%S)] $site is not reachable." | ./slack-post.sh
sudo apt-get install libmoose-perl libtemplate-perl libmoosex-types-path-class-perl libdatetime-perl libdatetime-format-w3cdtf-perl libtemplate-plugin-html-strip-perl libdata-guid-perl
@ledger123
ledger123 / dump.sh
Created October 18, 2021 06:19 — forked from andsens/dump.sh
Backup all MySQL databases into separate files
#!/bin/sh
## backup each mysql db into a different file, rather than one big file
## as with --all-databases. This will make restores easier.
## To backup a single database simply add the db name as a parameter (or multiple dbs)
## Putting the script in /var/backups/mysql seems sensible... on a debian machine that is
## Create the user and directories
# mkdir -p /var/backups/mysql/databases
# useradd --home-dir /var/backups/mysql --gid backup --no-create-home mysql-backup
## Remember to make the script executable, and unreadable by others
@ledger123
ledger123 / centos_swapfile.sh
Created October 29, 2021 14:51 — forked from mortenbra/centos_swapfile.sh
Creating a swapfile suitable for Oracle XE on CentOS
# Oracle XE requires a swap file of at least twice the size of physical memory
# see https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-6
# check current swap file
swapon -s
# check available space
df
# setup 2GB swap file
dd if=/dev/zero of=/swapfile bs=1024 count=2048k