#!/bin/bash
# http://www.crystalfaeries.net/posix/bin/backups				version	2012-08-21 17:50:27+00:00
# Released under GNU Lesser General Public License 3 by	celeste:crystalfaery	2012-08-21 17:51:11+00:00
# Linux(TM) is only a kernel, GNU is the root of freeware, and DebIan is the freest GNU

# List what is backed-up and the size thereof, and what is excluded from back-up
# note there are two levels of backup / exclusion combined...
# first  is the backup  by   rsnapshot  to		/.snapshots or /home/rsnapshot
# second is the backup from /.snapshots or /home/rsnapshot by darchive
# obviously if it was not backed-up by rsnapshot, darchive never sees it
# this helps us choose what to backup or exclude based on size when space limited
# my most recent install of rsnapshot defaulted to backing up to /var/cache/something
# notice also that while dar watches for CACHEDIR.TAG, we have other scripts here which
# scan the filesystem for CACHEDIR.TAG files and then edit automatically /etc/rsnapshot.conf
# adding to the end of the file after a specific text phrase as dividing boundary,
# the excludes for the containing directories
# note that rsnapshot is happy to accept a link as destination, so that by modifying the link
# you can actually store your rsnapshots anywhere they fit in your filesystems.
# Given my two presumed targets in my scripting here, if you link both to your actual storage, the scripts should keep working.
# Yes, a presumption here is that you're not merely a user boxed into your account, but can invoke admin permissions system wide.

for f in $(cat /etc/darexclude) ;do
	echo "excludar	/$f"
done																			 > /tmp/$$.exclude.txt

grep backup  /etc/rsnapshot.conf | grep -v \# | sed 's/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\tfaery\/$// ; s/\ttb\/$//'	>> /tmp/$$.exclude.txt
grep exclude /etc/rsnapshot.conf | grep -v \# | sed 's/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/'					>> /tmp/$$.exclude.txt

sudo nice find /.snapshots/hourly.0/ -type d -exec du -s {} \; 2>/dev/null \
	| sed 's/\/.snapshots\/hourly.0// ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\t/\t/ ; s/\t\/faery/\t/ ; s/\t\/tb/\t/'		>> /tmp/$$.exclude.txt
	  sed 's/\t\t/\t/ ; s/\t$//'															 < /tmp/$$.exclude.txt \
	| sort -u -k 2	# spew our report to standard out.


syntax highlighted by Code2HTML, v. 0.9.1