Site Tools


backup_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
backup_script [2025/05/03 13:41] thilobackup_script [2025/05/06 08:08] (current) – little typo thilo
Line 78: Line 78:
    done    done
        
-   BACKUPHOST=`ip r | grep ${ROUTER} | grep default | head -1 | cut -d " " -f 9`+   BACKUPHOST=`ip r | grep "${ROUTER%1}0/24" | head -1 | cut -d " " -f 9`
    echo    echo
    echo "Backup dir:  "${DIR2BACKUP}    echo "Backup dir:  "${DIR2BACKUP}
Line 135: Line 135:
         DATE=`date +%Y%m%d_%H%M`         DATE=`date +%Y%m%d_%H%M`
         if ! [[ `find -cmin 5 | grep ${THIS_BACKUP_FILE}` ]] ; then         if ! [[ `find -cmin 5 | grep ${THIS_BACKUP_FILE}` ]] ; then
-                # Date of the new files is more that 5 mind in the past  => seems Tomato Router has no date (or date 1970-01-01)+                # Date of the new files is more that 5 mins in the past  => seems Tomato Router has no date (or date 1970-01-01)
                 touch ${THIS_BACKUP_FILE}                 touch ${THIS_BACKUP_FILE}
         fi         fi
         # Keep only one file (the latest) per day - delete earlier file of same day             # Keep only one file (the latest) per day - delete earlier file of same day    
-        LIST_OLD_BACKUPS_OF_TODAY=`find -ctime 0 | grep ${ALL_BACKUP_FILES_PREFIX| grep -v ${THIS_BACKUP_FILE}`+        LIST_OLD_BACKUPS_OF_TODAY=`ls -${TODAYS_BACKUP_FILES_PREFIX}_${TIME_REGEX}.${EXT} 2> /dev/null | sed -e 1,1d`
         if [ "${LIST_OLD_BACKUPS_OF_TODAY}" ]; then         if [ "${LIST_OLD_BACKUPS_OF_TODAY}" ]; then
                 echo "deleting today's earlier backups (to keep just one per day - the most recent):"                 echo "deleting today's earlier backups (to keep just one per day - the most recent):"
backup_script.1746276105.txt.gz · Last modified: 2025/05/03 13:41 by thilo