The other day let’s put this in short, called out to do a job on Thursday night @ 4:30PM turn around at 3:30AM I was headed home from doing a recovery effort on a offsite location.

Well little here nor there, I have created a pretty little Script for anyone wanting to use this if they find themselves where their FreeBSD locks up, fstab is all borked, everything is array and you have another server you moved all files too just in case of hardware failure and have access via ssh. Where this script, you can move all of the samba/share files and folders in one shot that you gave temporary access to this server while you were fixing the failed Samba.

This script will move all the “Changed” files and folders and preserve all permissions and ownership so you don’t have to dig through and chown and chmod NOTHING. So in the few hours that these shared files were being accessed you can safely restore all the files back to Samba-1 server from Samba-2 server.

#!/bin/sh
# A advanced scp command to copy files, folders that have been modified after a specified time by WTFNIX.com
#
mkdir -p REVfiles
touch -t 0804250140 REVmark #Date and time format: year, month, day, hour minute
find $1 -newer REVmark | cpio -pdu REVfiles
cd REVfiles
tar -cf $1.tar $1
gzip $1.tar
scp $1.tar.gz root@IPADDRESS:/samba
cd ..
rm -rf REVfiles
rm -rf REVmark

I sure as hell hope this helps someone out if they need it, just copy the code and create a .sh script on their server using vi or whatever editor you use.

continue reading.....