Skip to content

Instantly share code, notes, and snippets.

@pujianto
pujianto / backup.sh
Last active May 20, 2020 02:37
Simple script to backup all mysql databases & store them on remote server (in silent mode)
#!/bin/sh
HOST="localhost"
USER="root"
PASSWORD="root"
DB="--all-databases"
DATE=`date +%Y-%m-%d.%H.%M.%S`
NAME="mysql.backup.${DB}.${DATE}.sql.gz"
COMMAND="mysqldump -h ${HOST} -u ${USER} -p$PASSWORD ${DB} | gzip -c > ${NAME}"
SCP_COMMAND="scp ${NAME} user@backup-server:/path/to/backup/folder/"
@pujianto
pujianto / startup script on vultr: add 2GB of SWAP
Last active June 8, 2017 12:10
Simple startup script on instance creation on vultr.com, for this case only updating repo and adding swap.
#!/bin/bash
#add swap
SWAP_SIZE="2G"
SWAP_MOUNT_NAME='/swapfile'
SWAP_EXISTS=`swapon -s`
SWAP_ON_STARTUP="$SWAP_MOUNT_NAME swap swap sw 0 0"
if [[ -z $SWAP_EXISTS ]] && [[ ! -f $SWAP_MOUNT_NAME ]] ; then
fallocate -l $SWAP_SIZE ${SWAP_MOUNT_NAME}