save changes script

pull/40/head
TomasM 2017-10-13 04:48:32 -04:00
parent 4ce0d58c5e
commit d0d0b28b84
2 changed files with 35 additions and 1 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
if [ "$2" = "" ]; then if [ "$2" = "" ]; then
echo "Usage: $0 [source directory] [target file.sb]" echo "Usage: $0 [source_directory] [target_file.sb]"
exit 1 exit 1
fi fi

34
tools/savechanges 100755
View File

@ -0,0 +1,34 @@
#!/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|^etc/ld[.]so[.]cache|^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" , -type f -print \) \
| sed -r "s/[.]\\///" | egrep -v "$EXCLUDE" \
| while read FILE; do
echo $FILE
cp -v --parents -afr $FILE $TMP
done
cd $CWD
mksquashfs $TMP "$1" -comp xz -b 512k -noappend
umount $TMP
rmdir $TMP