Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.