#!/bin/bash #pcboy.pebkac@gmail.com FOLDER=$1 usage() { echo "./preserveperms.sh FOLDER > ./restoreperms.sh"; exit } if [ ${#FOLDER} -eq 0 ];then usage fi echo "#Starting backup." 1>&2 for i in `find $FOLDER`;do echo -n "chmod "; echo -n "`stat -c %a $i` $i" echo -n "; chown " echo -n "`stat -c %U:%G $i` " echo $i done echo "#Finished. Now start restoreperms.sh ;)" 1>&2 if [ -f ./restoreperms.sh ];then chmod +x ./restoreperms.sh fi