Header First

This is a debugging block

Header Second

This is a debugging block

Branding

This is a debugging block

User Bar First

This is a debugging block

User Bar Second

This is a debugging block

Backupscript for Linux

Content

This is a debugging block

This bash script can be used on Linux to push daily backups to moldyn54. It will only store changes and not duplicate files.

#!/bin/bash

# CMM backupscript
# By Ward Poelmans

# This script will backup your $HOME directory to moldyn54.

# HOWTO
# You must have a pubkey on the moldyn54 for this to work automatically. How do you do this?
# Make a pubkey by running: ssh-keygen
# Copy the key to moldyn54: ssh-copy-id moldyn54

# How many backups should I keep? Note that we don't store a unchanged file twice,
# so you can have a high number here without having to worry about diskspace
NUMBACKUPS=31

# Where should I put my backups? Login to the moldyn54 and run the quota command to
# see where you quota is allocated.
WHEREBACKUPS=/mnt/archive0/username # CHANGE THIS TO YOUR SITUATION!

# Put this cron in a cronjob to run it automatically. Use the command "crontab -e" for this
# To run daily at 17h00, add: 0 17 * * * /home/username/backup.sh
# Change the path to you situation

# In the file $HOME/.exclude-backup.txt you can add any files that should not be backuped. This
# file will be created first time you run this script.

# The rest is just the actual script.

# Treat unset variables as an error
set -o nounset

# First run
if [ ! -f $HOME/.exclude-backup.txt ]; then
    touch $HOME/.exclude-backup.txt
    cat << EOF > $HOME/.exclude-backup.txt
${USER}/.cache/
${USER}/.thumbnails/
${USER}/.ccache/
${USER}/.gvfs/
${USER}/.local/share/Trash/
${USER}/.fontconfig/
EOF
    echo "Created $HOME/.exclude.txt"
fi

# The actual backup
rsync -q -h -a -X -b --exclude-from=${HOME}/.exclude-backup.txt --backup-dir=../backup.0/ --link-dest=../backup.0/ $HOME ward@moldyn54:${WHEREBACKUPS}/backup.cur/

# Rotate the backups
cat << EOF | ssh -T ward@moldyn54 > /dev/null

cd ${WHEREBACKUPS}

if [ ! -d backup.cur ]; then
    echo "No current backup found, exiting..."
    exit 1
fi

if [ -d backup.${NUMBACKUPS} ]; then
    mv backup.${NUMBACKUPS} backup.old
    rm -rf backup.old
fi

for I in \$(seq ${NUMBACKUPS} -1 0); do
    if [ -d "backup.\$I" ]; then
	let k=I+1
	mv "backup.\$I" "backup.\$k"
    fi
done

mv backup.cur backup.0

tail -n 100 latest-backup.txt > .tmp
echo \$(date) >> .tmp
mv .tmp latest-backup.txt

EOF

Postscript First

This is a debugging block

Postscript Second

This is a debugging block

Postscript Third

This is a debugging block

Preface First

This is a debugging block

Preface Second

This is a debugging block

Preface Third

This is a debugging block