Skip to content

Instantly share code, notes, and snippets.

@bglobal
bglobal / backup-vm.sh
Created May 25, 2018 14:42 — forked from timabell/backup-vm.sh
tar+lz4 backup with progress
#!/bin/bash -v
# backing up a vm
cd /media/tim/WD6/
base="/home/tim/VirtualBox VMs"
src=win10-2018
mv $src.tar.lz4 $src.tar.lz4.old

How rsync works

(source: https://sites.google.com/site/rsync2u/home/rsync-tutorial/how-rsync-works3)

~/demo1$rsync is efficient. The first time rsync is run, destination is created and the full source is copied to destination. Thereafter, only changes in source are copied to destination. If the --link-dest option is used, unchanged files are hard linked to the previous backup.

A hard link is a pointer to a file. Hard links have the advantage of using very little memory. There is an illustrated explanation of hard links on http://blog.interlinked.org/tutorials/rsync_time_machine.html > scroll down to “Hard-Links”.

Here is how the "rsync --link-dest=DIR" algorithm creates files in destination:

if destination does not exists,

@bglobal
bglobal / post-receive
Created May 25, 2018 14:54 — forked from geekforbrains/post-receive
Git post-receive rsync to remote server
#!/bin/bash
REPO=NAME_HERE
# Dir paths on remote server
# These are associated with branches within a git project
LIVE_BRANCH="master"
LIVE="git@host:/var/www/live/"
STAGE_BRANCH="develop"
STAGE="git@host:/var/www/stage/"
@bglobal
bglobal / AWS-config.md
Created June 11, 2018 23:32
Fucking Yes! AWS setup for Wordpress Server

Fucking Yes! AWS setup for Awesome Fast Wordpress Server

Ramblings and notes of my experiments with AWS which I will later turn into more coherent instructions.

Sooo... I'm about to be released into the wild as a free roaming web developer. I won't have the company hosting anymore and it's damn well about time I got my own shit sorted. After a little reading I have decided to give Amazon Web Services a try. So far I am loving it.

I have oooooooodles of control. It's super nerdy and more importantly, it's super fast. Seriously - I had fun.

When I first set this up i tried following some third party tutorials to get a wordpress server setup and running on Amazon Web Services. After some trial and error I found the proper documentation and everything when much more smoothly (I know right)! The AWS docs are very detailed and easy to follow.

Install PHP 7.1
sudo update-alternatives --set php /usr/bin/php7.0
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.1
php -v
PHP 7.1 Modules list (Example)
@bglobal
bglobal / 1. wpFormsToDatalyer.js
Created February 22, 2022 01:04 — forked from kmclaugh/1. wpFormsToDatalyer.js
Notifies the datalyer when a wpForm is submitted so Google Tag Manager can detect it
// This code notifies Google Tag Manager when a wpForm is submitted
document.addEventListener("DOMContentLoaded", function() {
var elementsArray = document.querySelectorAll('[id^="wpforms-form-"]');
elementsArray.forEach(function(elem) {
elem.addEventListener("submit", function(e) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "wpFormSubmit",
wpFormElement: event.target
});
@bglobal
bglobal / https_nginx_express_node_config.md
Created February 28, 2022 14:22 — forked from basharovV/https_nginx_express_node_config.md
How to configure HTTPS with Lets Encrypt, Nginx reverse proxy, Express and Node

How to configure HTTPS with Lets Encrypt, Nginx reverse proxy, Express and Node

  1. Have a Node app ready for production.
  2. Create an app.js file in your project directory:
const express = require('express');
const path = require('path');
const app = express();

// Allow dotfiles - this is required for verification by Lets Encrypt's certbot
@bglobal
bglobal / pg_backup_all.sh
Created March 15, 2022 21:00 — forked from powellc/pg_backup_all.sh
Bash script to backup all postgresql databases on a server, run with cron once a day or 5 times a day, whatever. Just updated it so it ignores your postgres db, and also bzips the backups and adds a symlink to a latest directory. Sweet.
#!/bin/bash
# Location to place backups.
backup_dir="/var/backups/databases/"
nightly_dir="/var/backups/databases/latest/"
#String to append to the name of the backup files
backup_date=`date +%d-%m-%Y`
#Numbers of days you want to keep copie of your databases
number_of_days=15
databases=`psql -l -t | cut -d'|' -f1 | sed -e 's/ //g' -e '/^$/d'`
for i in $databases; do if [ "$i" != "postgres" ] && [ "$i" != "template0" ] && [ "$i" != "template1" ] && [ "$i" != "template_postgis" ]; then
@bglobal
bglobal / example.com
Created April 7, 2022 20:35 — forked from 1hakr/example.com
Supercharge your NGIX config
proxy_cache_path /tmp/cacheapi levels=1:2 keys_zone=microcacheapi:100m max_size=1g inactive=1d use_temp_path=off;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name example.com;
location /api/ {
# Rate Limiting
limit_req zone=reqlimit burst=20; # Max burst of request
@bglobal
bglobal / vue-nginx.conf
Last active June 30, 2022 01:54 — forked from namdau/vue-nginx.conf
Nginx config for Vuejs project with an API upstream
server {
server_name default_server;
# This is for Let's Encrypt certification renewal
include /etc/nginx/snippets/letsencrypt.conf;
# Redirect to https
location / {
return 301 https://$server_name$request_uri;
}
}