Ignore sockets during tar backup
Login | Register RSS
09/20/2014 - Linux 

Ignore sockets during tar backup

If you want to skip error sockets-related code during backup of whole filesystem you will be surprised there's no –ignore-sockets switch.
But there's elegant method to to that:

cd /
sudo find . -type s > /tmp/sockets.lst
if sudo tar zcvpf $TMP_FILE --one-file-system --exclude-from=/tmp/sockets.lst -C / .
then
echo backup OK
fi

or how to get rid of tar’s “socket ignored” message

This based on a very useful tip in Darren Patterson’s blog, something I was looking for for quite a while:

When you want to filter out useless error from stderr messages, while keeping your stdout channel unaffected
(e.g., to get rid of the annoying 'socket ignored' warnings issued by old version of GNU tar), bash is your friend:

        tar   2> >(grep -v 'socket ignored' >&2)

If you like this site or any of its content, please help promote it. Use the social media buttons below to help spread the word. Don't forget to post in the comments section.

  Print   Email