Backup Settings, Logs, & More to USB Drive Script

This is a script that will back up all of your routers settings, logs, NVRAM data, bandwidth, web usage, sysinfo and more. It is very useful if you often make changes to your router and want the reassurance that your settings are being backed up. Their is nothing worse than doing a 30/30/30 reset and then thinking "…did I write down my settings…". Use this script if you would like to have your router back itself up to a usb storage device on a regular basis by using the scheduler. Also, this script makes use of router lights to let you know when the script is running and if it was successful.
Lets get started!

Here are the links to the latest versions.
Download for Tomato Full Backup Script
Readme for Tomato Full Backup Script

The Script - [The script show might not be the most up to date version, please use download link above]

ScriptName="Tomato Backup Script - 2011/08/05 - v9.6c - Written By: Austin Saint Aubin"
# Link to this Script: https://docs.google.com/document/d/1gxLsOR-WawC7tYzWt_zRexa5N3EzwlWy5QONzJO8YTI/edit?hl=en
# -------------------------------------------------------------------------------------------------
# Use "nvram set usb_disk_main=/tmp/mnt/USB_DISK" to set a global main usb disk location for all scripts.
# Use "nvram set usb_tomato=/tmp/mnt/USB_DISK/Tomato" to set a global tomato files/saves location for all scripts.
# -------------------------------------------------------------------------------------------------
# Gerneral Script Usage: sh $(nvram get usb_disk_main)/Tomato/Scripts/TomatoFullBackup.sh
# -------------------------------------------------------------------------------------------------
# WithNotes: sh $(nvram get usb_disk_main)/Tomato/Scripts/TomatoFullBackup.sh Here are some notes
# FullBackup: sh $(nvram get usb_disk_main)/Tomato/Scripts/TomatoFullBackup.sh full
# =================================================================================================

# [ General Variables ] ---------------------------------------------------------------------------
OS_VERSION=$(nvram get os_version)
OS_VERSION_UNDERSCORED=$(nvram get os_version | sed -e 's/ /_/g')
#   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
USB_Drive=$(nvram get usb_disk_tomato)
RootDIR=$USB_Drive
# BackupsLocation="$RootDIR/Tomato/Backups/$OS_VERSION_UNDERSCORED"
BackupsLocation="$RootDIR/Backups/$OS_VERSION"
NumOfBackupsToKeep=128

# [ Note Variables & Setup ] DO NOT EDIT ----------------------------------------------------------
BackupNotes="$(echo $@ | sed -e 's/ /_/g')" # Do Not Change This
if [ -n "$BackupNotes" ] && [ "$BackupNotes" != "full" ]; then
    BackupNote="_($BackupNotes)"
else
    BackupNote=""
fi

# [ Log Variables ] -------------------------------------------------------------------------------
LogDirectoy="$BackupsLocation"
LogFileName="TomatoFullBackup_Log"
LogLocation="$LogDirectoy/$LogFileName"_"$(date +%Y-%m-%d_%H%M%S)$BackupNote.txt"
# LogLocation="$LogDirectoy/$LogFileName.txt"
# echo -n "" > "$LogLocation"

# -------------------------------------------------------------------------------------------------
whatToBackUp()
{
    # This is where all the magic happens, change the backThisUp lines as you like.
    # backThisUp "(1)title of backup for note in logs", "(2) WEB - type of backup", "(3)save location", "(4)filename prefex", "(5)file extention/type", "(6)num of backups to keep", "(7)WEB URL Selector / SH Command / ARK Command", "(8)ARK Folder to Archive"
    backThisUp "Router Configuration" web "cfg/tomato_v128_mb60ee6.cfg" "$BackupsLocation/Configurations" "tomato_($OS_VERSION_UNDERSCORED)" cfg $NumOfBackupsToKeep
    ## backThisUp "System Log" sh "cat /tmp/var/log/messages" "$BackupsLocation/SysLogs" "syslog" txt $NumOfBackupsToKeep
    backThisUp "System Log" cp file "/tmp/var/log/messages" "$BackupsLocation/SysLogs" "syslog" txt $NumOfBackupsToKeep
    backThisUp SysInfo sh "sysinfo" "$BackupsLocation/SysInfo" "sysInfo" txt $NumOfBackupsToKeep
    backThisUp "NVRam Full List (Show-Raw)" nvram show "$BackupsLocation/NVRam/Show-Raw" "NVRam_($OS_VERSION_UNDERSCORED)" txt $NumOfBackupsToKeep
    backThisUp "NVRam Full List (Quote)" nvram quote "$BackupsLocation/NVRam/Quote" "NVRam_($OS_VERSION_UNDERSCORED)" txt $NumOfBackupsToKeep
    backThisUp "NVRam Full List (Quote Filtered)" nvram quote "$BackupsLocation/NVRam/Quote Filtered - Cross Importable" "NVRam_($OS_VERSION_UNDERSCORED)" txt $NumOfBackupsToKeep "clkfreq|ddnsx|dhcpd|ftp|http|lan_hostname|ntp|rstats|sch|script|sesx|smbd|usb|vpn_server_|vpn_server1|wan_dns|wan_hostname|wl0_" "Match-And-Remove-NOTHING"
    backThisUp "NVRam Full List (Set)" nvram set "$BackupsLocation/NVRam/Set" "NVRam_($OS_VERSION_UNDERSCORED)" txt $NumOfBackupsToKeep
    backThisUp "Web Domains" cp file "/proc/webmon_recent_searches" "$BackupsLocation/WebUsage/Domains" WebDomains txt $NumOfBackupsToKeep
    backThisUp "Web Searches" cp file "/proc/webmon_recent_searches" "$BackupsLocation/WebUsage/Searches" WebSearches txt $NumOfBackupsToKeep
    backThisUp "Scripts Backup" cp folder "/tmp/*.sh" "$BackupsLocation/Scripts-Backup" "Tomato-Scripts" $NumOfBackupsToKeep
    BRK 3
    wget -O - "http://admin:$(nvram get http_passwd)@$(nvram get lan_ipaddr)/bwm-daily.asp" >> /dev/null
    rstats
    sleep 3
    backThisUp "Bandwidth Usage" web "bwm/tomato_rstats_c03f0eb60ee6.gz" "$BackupsLocation/BandwidthUsage-Archive" tomato_rstats_c03f0eb60ee6 gz $NumOfBackupsToKeep

    # Backup Optware every Sunday.
    BRK 3
    if [ "Sun" == "$(date +%a)" ] && [ "1" == "$(date +%H)" ] || [ "$BackupNotes" == "full" ]; then
        say "Today is: $(date +%a) at 1:xx, backing up Optware."
        backThisUp "Archive Optware" ark "czf" "/opt" "$BackupsLocation/Optware-Archive" "Optware" "tar.gz" 8
        ### To Extract the Optware Archive:        http://www.dd-wrt.com/wiki/index.php/Optware#.2Fopt_backup
        # cd /; tar xvzf "$(nvram get usb_disk_main)/Tomato/Optware-Archive/Optware_2011-05-01_181510.tar.gz"
    else
        say "Today is ($(date +%a) at $(date +%H):xx) NOT: (Sun at 1:xx), waiting untell then to backing up Optware."
        say "However, you can use (TomatoFullBackup.sh \"full\"), have a look at Usage at the top of the script."
    fi
}

# ==========================================================================================================================================
# There is no need to edit anythign under this line.
# ==========================================================================================================================================

backThisUp()
{
    BRK 2 
    WHT "[Backuping up ($1]"

    DATE=$(date +%Y-%m-%d_%H%M%S)

    if [ -n "$BackupNotes" ] && [ "$BackupNotes" != "full" ]; then
        WHT "With Backup Note: \"$BackupNotes\""
    fi

    # cd "$3/"
    if [ $2 == sh ]; then
        # Shell Command
        output_file="$5_$DATE$BackupNote.$6"
        YEL "Using Shell Command: ($3) and logging to ($output_file)"
        checkFolder "$4"
        cleanupFiles "$4" "$5*.$6" "$7"
        # --------------------------------
        BLK "Output File: $output_file"
        BLK "Running Shell Command"
        BLK "$3"
        $3 > "$4/$output_file"
    elif [ $2 == web ]; then
        # Web Download
        YEL "Downloading with (wget)"
        output_file="$5_$DATE$BackupNote.$6"
        checkFolder "$4"
        cleanupFiles "$4" "$5*.$6" "$7"
        # --------------------------------
        BLK "Output File: $output_file"
        wget "http://root:$(nvram get http_passwd)@$(nvram get lan_ipaddr)/$3?_http_id=$(nvram get http_id)" -O "$4/$output_file"
    elif [ $2 == ark ]; then
        # File/Folder Archiving
        YEL "Archiving ($4) with ($3) to ($5)"
        output_file="$6_$DATE$BackupNote.$7"
        checkFolder "$5"
        cleanupFiles "$5" "$6*.$7" "$8"
        # --------------------------------
        BLK "Output File: $output_file"
        tar "$3" "$5/$output_file" "$4"
    elif [ $2 == cp ]; then
        # File/Folder Copy
        if [ $3 == file ]; then
            output_file="$6_$DATE$BackupNote.$7"
            file="$5/$output_file"
            YEL "Copying File: ($4) to ($file)"
            checkFolder "$5"
            cleanupFiles "$5" "$6*.$7" "$8"
            # --------------------------------
            BLK "Output File: $output_file"
            cp "$4" "$file"
            chmod 777 "$file"
        elif [ $3 == folder ]; then
            folder="$6_$DATE$BackupNote"
            YEL "Copying Folder/Dir: ($4) to ($folder)"
            cleanupFolder "$5" "$6_*" "$7"
            # --------------------------------
            BLK "Output Folder: $folder"
            checkFolder "$5/$folder"
            echo cp "$4" "$5/$folder"
            cp $4 "$5/$folder"
            chmod 777 "$5/$folder"
        else
            WRN "Copy Error ($3)"
        fi
    elif [ $2 == nvram ]; then
        checkFolder "$4"
        cleanupFiles "$4" "$5*.$6" "$7"
        # --------------------------------
        if [ $3 == quote ]; then
            output_file="$5"_"$DATE"_"(Quote)$BackupNote.$6"
            BLK "Output File: $output_file"
            YEL "NVRAM Quote"
            if [ -n "$8" ] || [ -n "$9" ]; then
                # Filtered NVRAM Backup
                YEL "Filtering In:  ($8)"
                YEL "Filtering Out: ($9)"
                nvram export --quote | egrep -i "($8).?+=" | egrep -i -v "($9).?+=" | sort | awk '{print "\#-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-\nnvram set " $0}' | sed 's/\\n/\n/g' | sed 's/\$/\\$/g' | sed 's/`/\\`/g' | sed 's/\\t/$(echo -e "\\t")/g' > "$4/$output_file"
                echo -e "# ===========================================================================\n# Filtered In:  ($8)\n# Filtered Out: ($9)" >> "$4/$output_file"
            else
                # Regular NVRAM Backup
                nvram export --quote | sort | awk '{print "\#-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-\nnvram set " $0}' | sed 's/\\n/\n/g' | sed 's/\$/\\$/g' | sed 's/`/\\`/g' | sed 's/\\t/$(echo -e "\\t")/g' > "$4/$output_file"
            fi
        elif [ $3 == set ]; then
            output_file="$5"_"$DATE"_"(Set)$BackupNote.$6"
            BLK "Output File: $output_file"
            YEL "NVRAM Set"
            if [ -n "$8" ] || [ -n "$9" ]; then
                # Filtered NVRAM Backup
                YEL "Filtering In:  ($8)"
                YEL "Filtering Out: ($9)"
                nvram export --set | egrep -i "($8).?+=" | egrep -i -v "($9).?+=" > "$4/$output_file"
                echo -e "# ===========================================================================\n# Filtered In:  ($8)\n# Filtered Out: ($9)" >> "$4/$output_file"
            else
                # Regular NVRAM Backup
                nvram export --set > "$4/$output_file"
            fi
        elif [ $3 == show ]; then
            output_file="$5"_"$DATE"_"(Show-Raw)$BackupNote.$6"
            BLK "Output File: $output_file"
            YEL "NVRAM Show-Raw"
            if [ -n "$8" ] || [ -n "$9" ]; then
                # Filtered NVRAM Backup
                YEL "Filtering In:  ($8)"
                YEL "Filtering Out: ($9)"
                nvram show | egrep -i "($8).?+=" | egrep -i -v "($9).?+=" > "$4/$output_file"
                echo -e "# ===========================================================================\n# Filtered In:  ($8)\n# Filtered Out: ($9)" >> "$4/$output_file"
            else
                # Regular NVRAM Backup
                nvram show > "$4/$output_file"
            fi
        else
            WRN "NVRAM Get Error ($3)"
        fi
    else
        WRN "backThisUp Error"
    fi

    BRK 4
    GRN "Backup of $1, Done"
}

# [ Support Functions ] ---------------------------------------------------------------------------
checkFolder() { [ -d "$@" ] && BLU "Folder Exists: $@" || (MAG "Making Folder: $@"; mkdir -p "$@"); } #CheckFolder - v4 - 2011/07/29
say() { echo "$@"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }

# COLOR( "Your Text" ) Only one color per line when logging ---------------------------------------
BLK() { echo -e "\033[30;40;1m$@\033[0m"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }
RED() { echo -e "\033[31;40;1m$@\033[0m"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }
GRN() { echo -e "\033[32;40;1m$@\033[0m"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }
YEL() { echo -e "\033[33;40;1m$@\033[0m"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }
BLU() { echo -e "\033[34;40;1m$@\033[0m"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }
MAG() { echo -e "\033[35;40;1m$@\033[0m"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }
CYN() { echo -e "\033[36;40;1m$@\033[0m"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }
WHT() { echo -e "\033[37;40;1m$@\033[0m"; echo "$@" >> "$LogLocation"; logger -t BackupToUSB "$@"; }
WRN() { echo -e "\033[31;40;1m/\033[33;40;1m!\033[31;40;1m\\ \033[33;40;1mWARNING:\033[37;40;1m $@ \033[31;40;1m/\033[33;40;1m!\033[31;40;1m\ \\033[0m"; echo "/!\\ WARNING: $@ /!\\" >> "$LogLocation"; logger -t BackupToUSB "/!\\ WARNING: $@ /!\\"; }
PASS() { echo -e "\033[30;40;1m$@ \t \033[37;40;1m[\033[32;40;1mPass\033[37;40;1m]\033[0m"; echo -e "$@ \t [Pass]" >> "$LogLocation"; logger -t BackupToUSB "$@ [Pass]"; }
FAIL() { echo -e "\033[37;40;1m$@ \t \033[37;40;1m[\033[31;40;1mFail\033[37;40;1m]\033[0m"; echo -e "$@ \t [Pass]" >> "$LogLocation"; logger -t BackupToUSB "$@ [Fail]"; }
# BRK( Number ) Line Formating Brake --------------------------------------------------------------
BRK()
{
    if [ $1 == 1 ]; then
        YEL "***===============*****===============***"
    elif [ $1 == 2 ]; then
        BLU "========================================="
    elif [ $1 == 3 ]; then
        BLK "~---------------------------------------~"
    elif [ $1 == 4 ]; then
        BLK "~ - - - - - - - - - - - - - - - - - - - ~"
    elif [ $1 == 5 ]; then
        BLK "........................................."
    else
        WRN "Break Formating ERROR [ $2 ]"
    fi
}

# checkDependencies [AppToCheck]
checkDependencies() # v2 - 2011-30-2011, Checks to make sure that the script has everything it needs to run. 
{
    # DependenciesList is the list of application this script needs to have avalible in order to run.
    if [ -z "$1" ]; then 
        DependenciesList="echo usleep sleep wget grep sed tar cp chmod rm rstats sh"
        YEL "Checking Scripts Dependencies"
        BLK "$DependenciesList"
    else
        DependenciesList="$1"
    fi

    BRK 5
    for DPCY in $DependenciesList; do
        DPCY_Location="$(which $DPCY)"
        if [ -z "$DPCY_Location" ]; then 
            FAIL "$DPCY"
            # WRN "Exiting script because of Dependency Failure"
            WRN "Dependency Failure, installation of [$DPCY] needed"

            if [ -n "$(which ipkg)" ]; then
                read -t 30 -n 1 -p "Would you like to install [$DPCY] by using \"ipkg\" (y/n)? "
                echo ""
                if [ "$REPLY" == "y" ] || [ "$REPLY" == "Y" ]; then
                    # echo "Choice: Yes"
                    BLK "Updating IPKG Package List"
                    ipkg update
                    MAG "Running IPKG Install of: $DPCY"
                    ipkg install "$DPCY"
                    # Call checkDependencies Function for DPCY and test to see if install was a success.
                    checkDependencies "$DPCY"
                else
                    # echo "Choice: No"
                    WRN "Exiting script because of Dependency Failure, install [$DPCY] manualy, or install optware and use it to install [$DPCY]"
                    exit 0
                fi
            else
                WRN "Exiting script because of Dependency Failure, install [$DPCY] manualy, or install optware and use it to install [$DPCY]"
                exit 0
            fi

        else
            PASS "$DPCY\t |\t $DPCY_Location"
        fi
    done

    BRK 5
    if [ -z "$1" ]; then 
        GRN "All Dependencies are Pressent. =^-^="
    fi
}

# cleanupFiles [DIR] [FileFilter] [NumOFilesKeep]
cleanupFiles()
{
    BRK 4
    CYN "Running Cleanup for $1/$2"
    YEL "Num of Backups to keep: $3"

    cd "$1/"

    BRK 5
    if [ "$(ls -A $2)" ]; then

        NumOFiles=$(find $2 | grep -v "/" | wc -l);
        i=$NumOFiles
        ls -1 $2  | grep -v "/" | while read file
        do
            # say "Checking($i): $file"
            BLK "Checking($(printf "%02d" $i)): $file"
            if [ $NumOFiles -gt $3 ]; then
                RED "[$NumOFiles > $3 ] Deleting #$i: $file"
                 rm -f "$file"
                NumOFiles=$(find $2 | grep -v "/" | wc -l);
            fi
            let i--
        done
    else
        RED "Folder: \"$1\" is empty of \"$2\""
    fi
    BRK 5
}

# cleanupFolder [DIR] [Filter] [NumOFilesKeep]
cleanupFolder()
{
    BRK 4
    CYN "Running Cleanup for $1/$2"
    YEL "Num of Backups to keep: $3"

    BRK 5
    if [ "$(ls -A "$1")" ]; then
        cd "$1/"

        NumOFolders=$(find $2 | grep -v "/" | wc -l);
        i=$NumOFolders
        ls -1 -d */ | while read folder
        do
            # say "Checking($i): $folder"
            BLK "Checking($(printf "%02d" $i)): $folder"
            if [ $NumOFolders -gt $3 ]; then
                RED "[$NumOFolders > $3 ] Deleting #$i: $folder"
                rm -f -R "$folder"
                NumOFolders=$(find $2 | grep -v "/" | wc -l);
            fi
            let i--
        done
    else
        RED "Folder: \"$1\" is empty of \"$2\""
    fi
    BRK 5
}

# Flash LED Script v1.3 2011/07/24
# Written By: Austin Saint Aubin
# flashLED( [LEDNAME] [SleepTime] [NumberOfTimes] [EndState] )
# flashLED( aoss 12500 5 off )
flashLED()
{
    BLK "Flash LED ($1) for ($2), $3 times."
    i=1
    while [ $i -le $3 ]; do
    logger -s -t FlashLED "Flash LED ($1) for ($2), $3 times. (Iterration: $i)"
    usleep $2
    led $1 on
    usleep $2
    led $1 off
    let i++
    done

    led $1 $4
}

###################################################################################################
echo "Starting Backup Script: $ScriptName"

# [ Main ] ========================================================================================
if [ -d "$USB_Drive" ]; then
    checkFolder "$RootDIR"
    checkFolder "$BackupsLocation"

    BRK 1
    WHT "***[Running Backup]*** $(date +%Y-%m-%d_%H%M%S)"
    RED "$ScriptName"
    CYN "$OS_VERSION"
    BRK 1

    if [ -n "$BackupNotes" ] && [ "$BackupNotes" != "full" ]; then
        WHT "With Backup Notes: \"$BackupNotes\""
        BRK 2
    fi

    checkDependencies
    BRK 2

    led aoss on
    say "USB Drive: $USB_Drive"
    say "Checking backup location: $(checkFolder "$BackupsLocation")"
    BRK 2

    BLK "Cleaning Old Logfiles in: $LogDirectoy"
    cleanupFiles "$LogDirectoy" "$LogFileName_*.txt" "$NumOfBackupsToKeep"
    BLK "Loging to: $LogLocation"
    # ====================================================================================
    whatToBackUp
    # ====================================================================================
    BRK 3

    #cp /tmp/scripts/TomatoFullBackup.sh "$BackupsLocation"
    led aoss off
    flashLED aoss 500000 3 off
    GRN "***[Backup Completed]*** $(date +%Y-%m-%d_%H%M%S)"
    # exit 1
else
    BLK2() { echo -e "\033[30;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    RED2() { echo -e "\033[31;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    GRN2() { echo -e "\033[32;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    YEL2() { echo -e "\033[33;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    BLU2() { echo -e "\033[34;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    MAG2() { echo -e "\033[35;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    CYN2() { echo -e "\033[36;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    WHT2() { echo -e "\033[37;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    WRN2() { echo -e "\033[31;40;1m/\033[33;40;1m!\033[31;40;1m\\ \033[33;40;1mWARNING:\033[37;40;1m $@ \033[31;40;1m/\033[33;40;1m!\033[31;40;1m\ \\033[0m"; logger -t BackupToUSB "/!\\ WARNING: $@ /!\\"; }
    BRK2() { echo -e  "~ - - - - - - - - - - - - - - - - - - - ~"; logger -t BackupToUSB "~ - - - - - - - - - - - - - - - - - - - ~"; }

    BRK2

    WRN2 "USB_Drive not set! (or) FlashDrive not valid"
    RED2 "USB_Drive is set to: \"$USB_Drive\""
    BRK2
    YEL2 "One way to fix this problem if the varable is not set is to do the following."
    WHT2 "Go to \"USB and NAS -> USB Support\" and in the \"Run after mounting\" box put the following if statement."
    WHT2 "\"nvram set usb_disk_main=/mnt/YOUR_USB_DISK\" (NO QUOTES)"
    WHT2 "\"nvram set rstats_path=$(nvram get usb_disk_main)/\""
    WHT2 "Click \"[SAVE]\""

    BRK2

    WRN2 "Exiting Script."
    BLK() { echo -e "\033[30;40;1m$@\033[0m"; logger -t BackupToUSB "$@"; }
    flashLED aoss 100000 10 on
fi

Setup
1. Download the script onto your USB Drive and save it to this location: "/mnt/YOUR_USB_DRIVE/Tomato/Scripts/TomatoFullBackup.sh"
2. Log into your router with the web interface. Usaly http://192.168.1.1
3. The go to "USB and NAS -> USB Support" and in the "Run after mounting" box put the following if statement.

checkFolder() { [ -d "$@" ] && logIt "Folder Exists: $@" || (logIt "Making Folder: $@"; mkdir -p "$@"); } #CheckFolder - v4 - 2011/07/29

if [ -d /mnt/USB_Disk ]; then
    nvram set usb_disk_main=/tmp/mnt/USB_DISK
fi

# Set Bandwith Save History Location
checkFolder "$(nvram get usb_disk_main)/Tomato/BandwidthUsage"
nvram set rstats_path=$(nvram get usb_disk_main)/Tomato/BandwidthUsage/

4. Click "[SAVE]"
5. Then go to “Administration -> Scheduler” and add the "Run Backup" command listed bellow to the "Command" field of Custom 1,2, or 3 just use one that's available.
# Run Backups
sh $(nvram get usb_tomato)/Scripts/TomatoFullBackup.sh Scheduled

6. Click "[SAVE]"
7. Setup Done!

Usage:
Use "nvram set usb_disk_main=/tmp/mnt/USB_DISK" to set a global main usb disk location for all scripts.
Use "nvram set usb_tomato=/tmp/mnt/USB_DISK/Tomato" to set a global tomato files/saves location for all scripts.


Gerneral Script Usage: sh $(nvram get usb_disk_main)/Tomato/Scripts/TomatoFullBackup.sh


WithNotes: sh $(nvram get usb_disk_main)/Tomato/Scripts/TomatoFullBackup.sh Here are some notes
FullBackup: sh $(nvram get usb_disk_main)/Tomato/Scripts/TomatoFullBackup.sh full


Also, the output of the script is now sent to the syslog, so you can now view everything in "Status -> Logs" from the web interface.


Please post feedback on this post here on the form

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License