<commit_before>#!/bin/bash
#
# This script actss as a frontend for rsnapshot. It checks to see if 
# my laptop is connected to my network at home, and if it is, then
# it fires up the backup.

LOG=/var/log/backup.log
BACKUP_DIR=/var/cache/rsnapshot

# Check to see if we're on my wireless LAN
#
# For reference, the output of iwconfig looks like this when associated:
#
# eth1      IEEE 802.11b/g  ESSID:"Seeker-WLAN"  Nickname:"Broadcom 4306"
#           Mode:Managed  Frequency=2.437 GHz  Access Point: 00:00:00:00:00:00   
#           Bit Rate=24 Mb/s   Tx-Power=15 dBm   
#           RTS thr:off   Fragment thr:off
#           Link Quality=60/100  Signal level=-62 dBm  Noise level=-72 dBm
#           Rx invalid nwid:0  Rx invalid crypt:30678  Rx invalid frag:0
#           Tx excessive retries:0  Invalid misc:0   Missed beacon:0


SSID=$(/sbin/iwconfig eth1 | grep ESSID | sed -e 's/^.*ESSID://' -e 's/ .*//' -e 's/"//g')

echo "====================================================" >> ${LOG}
if [ "${SSID}" != "Seeker-WLAN" ]
then
    echo "$(date): Not on home network" >> ${LOG}
    echo "  SSID = ${SSID}" >> ${LOG}
    exit 0
fi

#
# Since we may not be connected to the network all of the time, we run this
# script often, but only do the backups when the oldest backup of a given
# level is more than it's period old. So when weekly.0 is more than a week
# old then we do a weekly backup.
#

daySecs=$(( 24 * 60 * 60 ))
weekSecs=$(( $daySecs * 7 ))
monthSecs=$(( $daySecs * 365 / 12 ))

currTime=$(date '+%s')

#
# Always do a daily backup
#

echo "$(date): Started daily rsnapshot" >> ${LOG}
nice /usr/bin/rsnapshot daily >> ${LOG}
echo "$(date): Finished daily rsnapshot" >> ${LOG}

echo $(find ${BACKUP_DIR}/ -maxdepth 1 -name weekly.0) >> ${LOG}

weekStamp=$(find ${BACKUP_DIR}/ -maxdepth 1 -name weekly.0 -printf '%T@\n')

if [ $(( $weekStamp + $weekSecs + $weekSecs )) -lt $currTime ]
then
    # weekly.0 is more than two weeks old. Do a weekly backup.
    # We need to use two weeks since daily.6 will become weekly.0
    # and daily.6 is already a week old

    echo "$(date): Started weekly rsnapshot" >> ${LOG}
    nice /usr/bin/rsnapshot weekly >> ${LOG}
    echo "$(date): Finished weekly rsnapshot" >> ${LOG}
fi

monthStamp=$(find ${BACKUP_DIR}/ -maxdepth 1 -name monthly.0 -printf '%T@\n')

if [ $(( $monthStamp + $monthSecs + $monthSecs )) -lt $currTime ]
then
    # monthly.0 is more than two months old. Do a monthly backup.
    # weekly.4 will become monthly.0

    echo "$(date): Started monthly rsnapshot" >> ${LOG}
    nice /usr/bin/rsnapshot monthly >> ${LOG}
    echo "$(date): Finished monthly rsnapshot" >> ${LOG}
fi

<commit_msg>Removed extraneous echo from the log for backup.sh<commit_after>#!/bin/bash
#
# This script actss as a frontend for rsnapshot. It checks to see if 
# my laptop is connected to my network at home, and if it is, then
# it fires up the backup.

LOG=/var/log/backup.log
BACKUP_DIR=/var/cache/rsnapshot

# Check to see if we're on my wireless LAN
#
# For reference, the output of iwconfig looks like this when associated:
#
# eth1      IEEE 802.11b/g  ESSID:"Seeker-WLAN"  Nickname:"Broadcom 4306"
#           Mode:Managed  Frequency=2.437 GHz  Access Point: 00:00:00:00:00:00   
#           Bit Rate=24 Mb/s   Tx-Power=15 dBm   
#           RTS thr:off   Fragment thr:off
#           Link Quality=60/100  Signal level=-62 dBm  Noise level=-72 dBm
#           Rx invalid nwid:0  Rx invalid crypt:30678  Rx invalid frag:0
#           Tx excessive retries:0  Invalid misc:0   Missed beacon:0


SSID=$(/sbin/iwconfig eth1 | grep ESSID | sed -e 's/^.*ESSID://' -e 's/ .*//' -e 's/"//g')

echo "====================================================" >> ${LOG}
if [ "${SSID}" != "Seeker-WLAN" ]
then
    echo "$(date): Not on home network" >> ${LOG}
    echo "  SSID = ${SSID}" >> ${LOG}
    exit 0
fi

#
# Since we may not be connected to the network all of the time, we run this
# script often, but only do the backups when the oldest backup of a given
# level is more than it's period old. So when weekly.0 is more than a week
# old then we do a weekly backup.
#

daySecs=$(( 24 * 60 * 60 ))
weekSecs=$(( $daySecs * 7 ))
monthSecs=$(( $daySecs * 365 / 12 ))

currTime=$(date '+%s')

#
# Always do a daily backup
#

echo "$(date): Started daily rsnapshot" >> ${LOG}
nice /usr/bin/rsnapshot daily >> ${LOG}
echo "$(date): Finished daily rsnapshot" >> ${LOG}

weekStamp=$(find ${BACKUP_DIR}/ -maxdepth 1 -name weekly.0 -printf '%T@\n')

if [ $(( $weekStamp + $weekSecs + $weekSecs )) -lt $currTime ]
then
    # weekly.0 is more than two weeks old. Do a weekly backup.
    # We need to use two weeks since daily.6 will become weekly.0
    # and daily.6 is already a week old

    echo "$(date): Started weekly rsnapshot" >> ${LOG}
    nice /usr/bin/rsnapshot weekly >> ${LOG}
    echo "$(date): Finished weekly rsnapshot" >> ${LOG}
fi

monthStamp=$(find ${BACKUP_DIR}/ -maxdepth 1 -name monthly.0 -printf '%T@\n')

if [ $(( $monthStamp + $monthSecs + $monthSecs )) -lt $currTime ]
then
    # monthly.0 is more than two months old. Do a monthly backup.
    # weekly.4 will become monthly.0

    echo "$(date): Started monthly rsnapshot" >> ${LOG}
    nice /usr/bin/rsnapshot monthly >> ${LOG}
    echo "$(date): Finished monthly rsnapshot" >> ${LOG}
fi


{'fraction_non_alphanumeric': 0.15972876247880957, 'fraction_numerical': 0.028630627236767753, 'mean_word_length': 3.132295719844358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4959713', 'n_tokens_mistral': 1942, 'n_tokens_neox': 1789, 'n_words': 665}