SHARE
TWEET

mountbackups

a guest Jan 14th, 2013 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # (C) Misha Gale, 2013
  4. # Available under the "I give no fucks" license.
  5.  
  6. # The following three variables will need to be modified according to your backup settings. See
  7. # https://panel.bitfolk.com/backups/
  8. BASE=85.119.80.225:/data/backup/rsnapshot
  9. IP=85.119.82.13
  10. MOUNTS="hourly.0 hourly.1 hourly.2 hourly.3 hourly.4 hourly.5 daily.0 daily.1 daily.2 daily.3 daily.4 daily.5 daily.6 weekly.0 weekly.1 weekly.2 weekly.3 monthly.0 monthly.1 monthly.2 monthly.3 monthly.4 monthly.5"
  11.  
  12. INVOKEDAS=`basename $0`
  13. MODE=$1
  14.  
  15.  
  16. if [ "$MODE" != "mount" -a "$MODE" != "unmount" ]; then
  17.     if [ "$INVOKEDAS" = "unmountbackups" ]; then
  18.         MODE='unmount';
  19.     elif [ "$INVOKEDAS" = "mountbackups" ]; then
  20.         MODE="mount"
  21.     else
  22.         echo "USAGE: $INVOKEDAS <mount | unmount>"
  23.         exit 1;
  24.     fi
  25. fi
  26.  
  27. for MOUNT in $MOUNTS; do
  28.     MOUNTDIR=/mnt/backups/$MOUNT
  29.  
  30.     if mount|grep "$MOUNTDIR">/dev/null; then #unmount if already mounted
  31.         umount $MOUNTDIR
  32.     fi
  33.  
  34.     if [ "$MODE" = "mount" ]; then
  35.         mkdir -p $MOUNTDIR
  36.         mount $BASE/$MOUNT/$IP $MOUNTDIR
  37.     fi
  38.  
  39.     if [ "$MODE" = "unmount" -a -d "$MOUNTDIR" ]; then
  40.         rmdir $MOUNTDIR
  41.     fi
  42. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top