#!/bin/bash
# http://crystalfaeries.net/posix/bin/dudarsnapshot
# celeste:crystalfaery 2013-11-12 21:59:36+00:00
# update backup/filesystem status reports/documents/files

cd ~	# will shorten paths below
documents="/home/`whoami`/documents"

/usr/local/bin/backups	>  $documents/backups.`hostname`.txt	# tree	of     backups

/usr/local/bin/durs	>     $documents/durs.`hostname`.txt	# du	of     backups

#								# du	of non-backups
cp /dev/null			    /tmp/dirs.`hostname`.txt
cp /dev/null			   /tmp/files.`hostname`.txt
cp /dev/null		     $documents/links.`hostname`.txt
cp /dev/null		     $documents/nulls.`hostname`.txt
# nice ionice -c 3 find / \( \( -path /home/rsnapshot -prune \) -o \( -path /.snapshots -prune \) -o \( -path /dev -prune \) -o \( -path /proc -prune \) -o \( -path /sys -prune \) -o \( -path /tmp -prune \) -o \( -path /var/tmp -prune \) -o \( -path /var/cache -prune \) -o \( -type d -fls /tmp/dirs.`hostname`.txt \) -o \( -type f -fls /tmp/files.`hostname`.txt \) -o \( -type l -fls $documents/links.`hostname`.txt \) -o \( -size 0 -fls $documents/nulls.`hostname`.txt \) \) 2>> $documents/"dudarsnapshot".`hostname`.txt
nice find / \( \( -path /home/rsnapshot -prune \) -o \( -path /.snapshots -prune \) -o \( -path /dev -prune \) -o \( -path /proc -prune \) -o \( -path /sys -prune \) -o \( -path /tmp -prune \) -o \( -path /var/tmp -prune \) -o \( -path /var/cache -prune \) -o \( -type d -fls /tmp/dirs.`hostname`.txt \) -o \( -type f -fls /tmp/files.`hostname`.txt \) -o \( -type l -fls $documents/links.`hostname`.txt \) -o \( -size 0 -fls $documents/nulls.`hostname`.txt \) \) 2>> $documents/"dudarsnapshot".`hostname`.txt

# we need to alter this to handle "ls -dils" output format for sort by decreasing size:
sort -rn	 /tmp/dirs.`hostname`.txt >	     $documents/dirs.`hostname`.txt	\
   && rm         /tmp/dirs.`hostname`.txt						\
   || rm -i	 /tmp/dirs.`hostname`.txt
sort -rn	/tmp/files.`hostname`.txt >	    $documents/files.`hostname`.txt	\
   && rm        /tmp/files.`hostname`.txt						\
   || rm -i	/tmp/files.`hostname`.txt

for file in files dirs durs backups links nulls dudarsnapshot	# in reverse viewing order
do
	touch					  $documents/"$file".`hostname`.txt
	sleep	61	# timestamp for viewing with:   "vi `ls -t $documents/*.txt`"
done


syntax highlighted by Code2HTML, v. 0.9.1