Another duplicity backup script template

After much deliberation, I've decided on a backup strategy.  I will backup any given computer on a computer in my local network, or a USB hard drive.  In addition to that I will give a hard drive to one of my friends for safe keeping and backup to that hard drive from time to time, when I visit him.  It isn't an ideal backup solution for several reasons.  For example, I might forget to backup because it isn't automated and I have to travel to make an offsite backup but it does protect me in the event that my house was to burn down and I don't have to pay monthly costs to a backup service.  I'm still testing it out, so we will see how it goes and how much I like the backup strategy.

Here is a template I created for backing up my personal computers using duplicity.  All I need to do is change a few parameters at the top of the script to backup to a different device or even a dedicated backup server on the internet.

Enjoy!

#!/bin/bash

# Backup all important files on my computer using Duplicity

# Folders to include
include_directories=(/home/me /etc)

# Folders to exclude
exclude_directories=()

# duplicity path to backup to.
destination=ssh://otherComputer/backup/myComputer

# Set passphrase
export PASSPHRASE="Secure passphrase here.  Don't forget to back me up!"

# Log directory
LOG_DIRECTORY=/home/me/log

# ======= NOTICE ================================
# You probably don't need to edit below this line.
# You have been warned!
# ================================================

# If duplicity is already running then exit
if [ $(ps aux | grep 'duplicity' | grep -v 'grep\|duplicity_backup.sh' | wc -l | tr -s "\n") -ne 0 ]; then 
  echo "Duplicity is already running, exiting."
  #exit
fi

include_parameters=""
for include_directory in ${include_directories[*]}
do
  include_parameters="$include_parameters --include $include_directory"
done

exclude_parameters=""
for exclude_directory in ${exclude_directories[*]}
do
  exclude_parameters="$exclude_parameters --exclude $exclude_directory"
done

TIMESTAMP=`date +%m%d%Y%H%M`

# Run duplicity command
BACKUP_LOG_FILE="$LOG_DIRECTORY/duplicity_backup_$TIMESTAMP.log"

duplicity \
  $include_parameters $exclude_parameters \
  --exclude '**' \
  --full-if-older-than 1Y \
  / "$destination" > $BACKUP_LOG_FILE

# Only keep around 1 full backup.
echo -e '\n\n==== REMOVE OLD BACKUP SETS ====\n\n' >> $BACKUP_LOG_FILE
duplicity remove-all-but-n-full 1 \
  "$destination" >> $BACKUP_LOG_FILE

cat $BACKUP_LOG_FILE

# Clear passphrase
export PASSPHRASE=