#!/bin/bash TMP=/tmp/changes$$ CHANGES=/mnt/live/memory/changes EXCLUDE="^\$|/\$|[.]wh[.][.]wh[.]orph/|^[.]wh[.][.]wh[.]plnk/|^[.]wh[.][.]wh[.]aufs|^var/cache/|^var/backups/|^var/tmp/|^var/log/|^var/lib/apt/|^var/lib/dhcp/|^var/lib/systemd/|^sbin/fsck[.]aufs|^etc/resolv[.]conf|^etc/fstab|^boot/|^dev/|^mnt/|^proc/|^run/|^sys/|^tmp/" if [ "$1" = "" ]; then echo "Usage: $0 [ target_file.sb ]" exit 1 fi # exclude the safe_file itself of course EXCLUDE="$EXCLUDE|^""$(readlink -f "$1" | cut -b 2- | sed -r "s/[.]/[.]/")""\$" CWD=$(pwd) cd $CHANGES || exit mkdir -p $TMP mount -t tmpfs tmpfs $TMP find \( -type d -printf "%p/\n" , -not -type d -print \) \ | sed -r "s/^[.]\\///" | egrep -v "$EXCLUDE" \ | while read FILE; do cp --parents -afr "$FILE" "$TMP" done cd $CWD mksquashfs $TMP "$1" -comp xz -b 512k -noappend umount $TMP rmdir $TMP