#!/bin/bash
# /usr/local/bin/tails-persistence-update.sh
# http://crystalfaeries.net/posix/bin/tails-persistence-update.sh
# celeste:crystalfaery 2015-08-22 16:07:49+00:00
# Update :
# /media/celeste/TailsData/apt/
# /media/celeste/TailsData/bookmarks/
# /media/celeste/TailsData/cups-configuration/
# /media/celeste/TailsData/dotfiles/
# /media/celeste/TailsData/electrum/
# /media/celeste/TailsData/gnome-keyrings/
# /media/celeste/TailsData/gnupg/
# /media/celeste/TailsData/icedove/
# /media/celeste/TailsData/live-additional-software.conf
# /media/celeste/TailsData/lost+found/
# /media/celeste/TailsData/nm-system-connections/
# /media/celeste/TailsData/openssh-client/
# /media/celeste/TailsData/pidgin/
# /media/celeste/TailsData/persistence.conf
# /media/celeste/TailsData/Persistent/
# /media/celeste/TailsData/Persistent/survivor/
exit -1 ####### REWRITE IN PROGRESS: this is our edit marker #######
# This script is manually executed to update the encrypted persistent storage:
# Plugin USB stick brings up LUKS mount dialogue, then once mounted...
# cd /media/TailsData/Persistent
# ./.update.sh
# cd
# sudo umount /media/TailsData
#
# At the same level the file .exclude.txt controls NON-copying.
# At the end of the update we generate a report in .du.txt
# showing us disk usage of what was or was not backed-up,
# in order to help us manually update the .exclude.txt file
# to optimize what is important to us to carry encrypted.
/usr/local/bin/synctxt # merge .todo lists
# we operate in the cloned home directory ####### ####### ####### #######
mkdir -p /media/TailsData/Persistent/home || exit 1
cd /media/TailsData/Persistent/home || exit 2
# EXCLUSION IMPLIES DELETE
cat ../.exclude.txt | sudo xargs rm -rf
# sync /home ( NOTE: paths in .exclude.txt are relative to source /home )
sudo rsync -auvzH --delete --exclude-from=../.exclude.txt --exclude='.*.swp' --exclude=local --exclude=www/cgi-bin /home ..
# sync /usr/local to /media/TailsData/Persistent/home/local
sudo rsync -auvzH --delete \
--exclude-from=../.exclude.txt \
--exclude='.*.swp' \
--exclude=games/ \
--exclude=iso/ \
--exclude=lib/ \
--exclude=src/ \
/usr/local .
# sync /usr/lib/cgi-bin/
sudo rsync -auvzH --delete /usr/lib/cgi-bin www
# sync bookmarks BIDIRECTIONALLY
rsync -auvzH /home/kahealani/.mozilla/firefox/*.default/bookmarks.html \
kahealani/.mozilla/firefox/*.default/bookmarks.html
rsync -auvzH kahealani/.mozilla/firefox/*.default/bookmarks.html \
/home/kahealani/.mozilla/firefox/*.default/bookmarks.html
# now we operate in the Persistent directory ####### ####### ####### #######
cd /media/TailsData/Persistent || exit 2
# calculate disk usage report
cp /dev/null /tmp/du.$$.txt
for d in `cat .exclude.txt`
do
du -s /home/$d | sed 's/\/home\///g' >> /tmp/du.$$.txt
done
df --full | head -n 1 > .du.txt # Captions
df --full | grep /media/Tails >> .du.txt # This partition
echo "" >> .du.txt
echo " EXCLUDED:" >> .du.txt
# filter out our overhead files
grep -v .du.txt /tmp/du.$$.txt |\
grep -v .exclude.txt |\
grep -v .update.sh |\
sort -rn >> .du.txt
echo "" >> .du.txt
echo " INCLUDED:" >> .du.txt
/usr/local/bin/dudir |\
sed 's/\/media\/TailsData\/Persistent\/home\///' >> .du.txt
# manually review our choice of exclusions
vi .du.txt .exclude.txt .update.sh
# copy from the Flash Drive to local hard disk to allow copying to other Flash Drives
rsync -auvzH .du.txt ~/txt/tails.du.txt
rsync -auvzH .exclude.txt ~/txt/tails.exclude.txt
rsync -auvzH .update.sh /usr/local/bin/tails.update.sh
syntax highlighted by Code2HTML, v. 0.9.1