Skip to content

Instantly share code, notes, and snippets.

@mikedevita
Created January 17, 2018 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikedevita/8bdb2789ee34048ceaab1493ea6abcce to your computer and use it in GitHub Desktop.
Save mikedevita/8bdb2789ee34048ceaab1493ea6abcce to your computer and use it in GitHub Desktop.
#!/bin/bash
BACKUPDIR="/mnt/config-backup/backups/phxlp-stg01.devita.co"
DATE="$(date '+%s')"
MAJORVERSION="$(cat /etc/version | cut -d'-' -f2)"
MINORVERSION="$(cat /etc/version | cut -d'-' -f3 | cut -d ' ' -f1)"
BACKUPFILENAME="freenas-${MAJORVERSION}-${MINORVERSION}-${DATE}.db"
DELETEOLDERTHAN="14"
DELETEOLDFILES=true
if [ "$DELETEOLDFILES" = true ] ; then
#find /mnt/config-backup/backups/phxlp-stg01.devita.co/*.db -mtime +60 -exec rm {} \;
echo "Deleting files older than 14 days";
find "/mnt/config-backup/backups/phxlp-stg01.devita.co/" -name "*.db" -mtime +14 -exec rm {} \;
fi
cp -f /data/freenas-v1.db "${BACKUPDIR}/${BACKUPFILENAME}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment