# Start not at index 0 but at one for windows
set -g base-index 1
+
+# vi copy and pasting
+bind-key -T copy-mode-vi 'v' send -X begin-selection
+bind-key -T copy-mode-vi 'y' send -X copy-selection
+bind-key -T copy-mode-vi 'Space' send -X halfpage-down
+bind-key -T copy-mode-vi 'Bspace' send -X halfpage-up
--- /dev/null
+#!/bin/sh
+trap 'um' 0 1 3 6 15
+um ()
+{
+ if mountpoint -q /mnt/backupdrive; then umount /mnt/backupdrive; fi
+}
+
+start="$(date)"
+if [ ! -n "$1" ]
+then
+ echo "Was this script called from udev? I need the ID_FS_UUID_ENC variable" | tee /home/mrl/backup.log
+ exit 1
+elif mountpoint -q /mnt/backupdrive
+then
+ cat<<MAIL | su -c 'ssh helheim /usr/lib/sendmail backups@martlubbers.net' mrl
+To: mart@martlubbers.net
+From: backups@martlubbers.net
+Subject: Backup failed ($start)
+Backup failed at at $(date) because /mnt/backupdrive was already a mountpoint
+MAIL
+elif mount -U "$1"
+then
+ mkdir -p /mnt/backupdrive/home/mrl /mnt/backupdrive/mnt/data &&\
+ rsync --delete --bwlimit=20M --exclude 'minidlna/*' --exclude 'transmission/ipt/*' -va /mnt/data/ /mnt/backupdrive/mnt/data > /home/mrl/backup.log &&\
+ rsync --delete --bwlimit=20M -va /home/mrl/ /mnt/backupdrive/home/mrl >> /home/mrl/backup.log &&\
+ umount /mnt/backupdrive &&\
+ cat<<MAIL | su -c 'ssh helheim /usr/lib/sendmail backups@martlubbers.net' mrl
+To: mart@martlubbers.net
+From: backups@martlubbers.net
+Subject: Backup finished ($start)
+Successfully finished at $(date)
+MAIL
+fi
--- /dev/null
+ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd?", RUN+="/bin/sh -c 'echo /home/mrl/.local/bin/backup.sh %E{ID_FS_UUID_ENC} | batch'"