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:
sudo find . -type s > /tmp/sockets.lst
if sudo tar zcvpf $TMP_FILE --one-file-system --exclude-from=/tmp/sockets.lst -C / .
echo backup OK
or how to get rid of tar’s “socket ignored” message
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.
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)