corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
corz.org text viewer..
[currently viewing: / public/ linux/ usr/ local/ bin/ corz-grabdbs.sh - raw]
if [ -z $1 ]; then
echo
echo "Please supply a domain name on the command-line. e.g.."
echo
echo "$0 foobar.net"
echo
echo "grabcomments will then use settings file: ~/.sftp/foobar.net"
echo
exit 1
fi
. ~/.sftp/$1
newname=$now.$host.db-bax.tar.gz
mytmp=$db_tmp/db
mystore=$dbstore/db
if [ ! -e $mytmp ]; then
mkdir -pv $mytmp &> /dev/null
fi
if [ ! -e $mystore ]; then
mkdir -pv $mystore &> /dev/null
fi
for elem in ${dbfiles[*]} ; do
cp -r $elem $mytmp/
done
echo "Zipping and archiving backup.."
cd $mytmp
cd ..
tar cfz $newname db >> $logfile
mv $newname $mystore/
cd
rm -rf $mytmp &> /dev/null
remount &> /dev/null
if [ ! -d $ol_db ]; then
mkdir -pv $ol_db &> /dev/null
fi
if [ -e "$ol_db" ];then
echo -n "Copying db backup to offline storage facility.. "
cp $mystore/$newname $ol_db/
if [ -e "$ol_db/$newname" ];then
echo "Success!"
rm $mystore/$newname >> $logfile &> /dev/null
rmdir $mystore &> /dev/null
rmdir $dbstore &> /dev/null
else
echo "Fail!"
echo "Could not copy $mystore/$newname to $ol_db"
fi
echo
fi
echo "Performing sftp operations for $user@$host.."
sftp -b "/usr/local/bin/$host/grabdbs" $user@$host
rc=$?
if [ $rc != 0 ] ; then
echo "**WARNING** grabdbs sftp for $host returned an error: $rc"
echo "**WARNING** grabdbs sftp for $host returned an error: $rc"|mailx -s "Error in up grabdbs sftp!" postmaster
exit $rc
fi
rmdir $db_tmp &> /dev/null
rmdir $arcroot &> /dev/null
echo "Setting local file permissions.."
for elem in ${dbfiles[*]} ; do
chmod 777 $elem
done
now=`date "+%Y.%m.%d-%H.%M"`
command -v fortune >/dev/null 2>&1 || { echo "Smile! It's Live!"; exit 0; }
fortune
echo "grabdbs for $host complete at $now"
exit 0