Created
January 17, 2018 22:32
-
-
Save mikedevita/8bdb2789ee34048ceaab1493ea6abcce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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