Other day, I was trying to copy the proc folder with following command:
tar cvzf /tmp/proc.tgz /proc
and I found out that all the files in tar were empty. Strange it may seem but lot of people are facing this as /proc is not a regular filesystem, so I wrote a quick script to copy the proc folder. Here is the script:
cd /
mkdir /tmp/proc
[[ -z $1 ]] && exit -1
find /proc/$1/ -not -name pagemap | while read F ; do
D=/tmp/$F
if [[ -d $F ]]
then
echo "$(ls -ld $F) => Directory"
mkdir -p $D
fi
if [[ -L $F ]]
then
echo "$(ls -ld $F) => copied"
cp -P $F /tmp/$F
elif [[ -f $F ]]
then
echo "$(ls -ld $F) => Cat"
cat $F > /tmp/$F
else
echo "Dont know $F"
fi
done