Linux archive files over 180 days

# a short script for at to run, to ship files off to the archive location
# eositis 18 oct 2010
# Version 2.0 updated for the new production envrironment

test=`date --date="180 days ago" +"%m%d%y"`
echo "mounting the archive location"
mount SERVERNAME:/shares/backup /mnt/tmp
echo "checking if the local archive directory exists"
[ ! -d /mnt/local/archive ] && mkdir /mnt/local/archive # Change this line to match local archive path
echo "searching for files older than 180 days"
find /mnt/dir-to-archive -maxdepth 1 -type f -mtime +180 -exec mv {} /mnt/local/archive \;
echo "this is the list of files to archive:"
ls -al /mnt/local/archive
echo "archiving the files to SERVERNAME:/shares/backup/$test.archive.tgz"
cd /mnt/dir-to-archive
tar --remove-files -cvzf /mnt/tmp/$test.prnFiles.tgz archive
echo "unmounting archive location"
umount /mnt/tmp
echo "sending completion message"
mail -s 'ran the archive. check result.' < /root/log/delscript.log

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s