bash

Find folder sizes on Ubuntu

Scenario

I needed to find out the amount of data stored in a group of folders. Each of the folders contains a web site, and I want to track the sites on-disk usage statistics.

Prerequisites

Linux system running bash.

du binary (typically induced in linux base install or busybox.

Tested on Ubuntu 12.

Command

du -shc *

Explanation:
s ..... Summary
h ..... Human Readable. K, M, and G for sizes.
c ..... Summary or Total
* ..... All files or folders in the current directory.

Add SWAP disk on Amazon EC2 Ubuntu servers

Scenario

My Ubuntu web servers were killing processes due to low free memory. I would prefer them to slow down than to kill processes. So I added SWAP disk space that is not setup by default in the EC2 instances.

Prerequisites

Amazon AWS EC2 Ubuntu 11 or 12 instance.

This may work on other Linux versions, but I have only used it on Ubuntu.

Backup Shell Script for Linux Web Host

Scenario

Backup multiple web sites stored on a Linux server. Sites are stored in a single folder as sub-folders.

I run a web host that is a custom fault tolerant solution on Amazon AWS t1.micro hosts. The primary host should be backed up daily, but a historic backup was necessarily. My goal was to have two weeks of daily backups. The sites databases are backed up separately, so my primary concern was the folder contents.