Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Little help with scripts

Featured Replies

I'd like to learn how to write my own scripts as a complete noob. And when I say scripts I'm talking specifically about the HTML kind used in the User Scripts plugin. Any advice on resources will be appreciated.

 

In the meantime I'd really like to get my local backups started. I want to use @dlandon's sample script to copy a few shares to an external Easystore USB drive. 

When I plug in the USB drive I'd like to automatically backup via rsync:
- /mnt/user/appdata            (to a folder on the USB drive called: appdata)

- /mnt/user/Media/photos    (to a folder on the USB drive called: photos)

- /mnt/user/nextcloud          (to a folder on the USB drive called: nextcloud)

- /mnt/user/backups/flashdrive backup      (to a folder on the USB drive called: flash backup)

- /mnt/user/system              (to a folder on the USB drive called: system)

 

(Is it necessary to backup my docker.img and libvert.img files)
 

Using the example script below, where do I define the destination? And how to I include multiple sources and multiple destinations? Is there anything else I'd need to change? I know this is a huge ask. Thank you. 

 

#!/bin/bash
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
## Available variables: 
# AVAIL      : available space
# USED       : used space
# SIZE       : partition size
# SERIAL     : disk serial number
# ACTION     : if mounting, ADD; if unmounting, UNMOUNT; if unmounted, REMOVE; if error, ERROR_MOUNT, ERROR_UNMOUNT
# MOUNTPOINT : where the partition is mounted
# FSTYPE     : partition filesystem
# LABEL      : partition label
# DEVICE     : partition device, e.g /dev/sda1
# OWNER      : "udev" if executed by UDEV, otherwise "user"
# PROG_NAME  : program name of this script
# LOGFILE    : log file for this script

case $ACTION in
  'ADD' )
    #
    # Beep that the device is plugged in.
    #
    beep  -l 200 -f 600 -n -l 200 -f 800
    sleep 2

    if mountpoint -q $MOUNTPOINT; then
      if [ $OWNER = "udev" ]
      then
        beep  -l 100 -f 2000 -n -l 150 -f 3000
        beep  -l 100 -f 2000 -n -l 150 -f 3000

        logger Started -t$PROG_NAME
        echo "Started: `date`" > $LOGFILE

        logger Pictures share -t$PROG_NAME
        rsync -a -v /mnt/user/Pictures $MOUNTPOINT/ 2>&1 >> $LOGFILE

        logger Syncing -t$PROG_NAME
        sync -f $MOUNTPOINT

        beep  -l 100 -f 2000 -n -l 150 -f 3000
        beep  -l 100 -f 2000 -n -l 150 -f 3000
        beep  -r 5 -l 100 -f 2000

        logger Unmounting PicturesBackup -t$PROG_NAME
        /usr/local/sbin/rc.unassigned umount $DEVICE

       echo "Completed: `date`" >> $LOGFILE
        logger Pictures Backup drive can be removed -t$PROG_NAME

        /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Server Backup" -d "Pictures Backup completed" -i "normal"
    fi
    else
        logger Pictures Backup Drive Not Mounted -t$PROG_NAME
  fi
  ;;

  'REMOVE' )
    #
    # Beep that the device is unmounted.
    #
    beep  -l 200 -f 800 -n -l 200 -f 600
  ;;

  'ERROR_MOUNT' )
	/usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Server Backup" -d "Could not mount Pictures Backup" -i "normal"
  ;;

  'ERROR_UNMOUNT' )
	/usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Server Backup" -d "Could not unmount Pictures Backup" -i "normal"
  ;;
esac

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.