Skip to content

Instantly share code, notes, and snippets.

@UnixSage
Created July 30, 2021 14:27
Show Gist options
  • Save UnixSage/674826f4e83adfe3eabec1ee998b75cc to your computer and use it in GitHub Desktop.
Save UnixSage/674826f4e83adfe3eabec1ee998b75cc to your computer and use it in GitHub Desktop.
Shell script that calls dump with an exclude list
#!/bin/sh
if [ $# = 2 ] ; then
NODENAME=$1
LEVEL=$2
elif [ $# = 1 ] ; then
NODENAME=$HOSTNAME
LEVEL=$1
else
NODENAME=$HOSTNAME
LEVEL=0
fi
SKIPLIST="
/usr
/data
/var/lib/flatpak
/var/cache
/home/SomeUser/.cache
"
INODELIST=`ls -1id ${SKIPLIST} | awk '{ORS=","; if($1 != "2") {print $1}}' | sed 's/,$//'`
DATESTAMP=`date +'%Y%m%d%H%M'`
echo dump -u -e ${INODELIST} -${LEVEL} -L ${DATESTAMP}-${LEVEL} -f ${NODENAME}.${DATESTAMP}-root-${LEVEL}.dmp /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment