#!/bin/sh # source file directory srcd=/usr/local/elog/ # backup all files newer than 25 hours date=$(date -d "-25hours" "+%Y%m%d %H:%M") # backup file directory tard=/logbooks_backup # backup tar file name tarf=$tard/$(date +%Y%m%d_%a.tar) # do not backup files that match patterns in this file excf=/usr/local/elog/utilities/exclude-logbooks # create backup cd $srcd tar --ignore-case -X $excf --newer "$date" -cf $tarf . logbooks/* # copy passwd.txt if [ "$(date +%u)" -eq 1 ] then passwd=$tard/passwd_$(date +%Y%m%d_%a.txt) cp $srcd/passwd.txt $passwd gzip -9 $passwd fi # delete all backups older than 90 days find $tard -mtime +90 -name "*_???.tar" -exec rm -f {} + find $tard -mtime +90 -name "passwd_*_???.txt.gz" -exec rm -f {} +