Blog Archive for December 21, 2011

BASH Functions

December 21, 2011

If you have repetitive code inside a bash script, it's possible to abstract it out into a function. Here's an example used for backing up postgres databases, and compressing the resulting sql file.

#!/bin/bash

export FILENAMEDATE=`date +%Y%m%d-%H%M%S`

function backup {
  export DATABASE=$1
  export USER …

SSH Without Password

December 21, 2011

It's possible to use SSH without being prompted for a password. This is useful for automated backup scripts, etc.

Create Key

First create a key

$ ssh-keygen

Copy Key to Remote Server

Next, copy the key to the remote server

$ ssh-copy-id remote@server.co.uk

This will prompt for the remote user …

Tags: ssh