CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Posted by jmbarnes on Thu 19th Aug 15:28 (modification of post by jmbarnes view diff)
diff | download | new post

  1. #/bin/bash
  2. ###
  3. ###Variables
  4. BACKUPTIME="`date +%m_%d_%Y`"
  5. INCREMENTS="PATH TO INCREMENTS/$BACKUPTIME"
  6. EXCLUDES="TEXT FILE OF THINGS TO EXCLUDE"
  7. SOURCEDIR="DIRECTORY TO BACKUP"
  8. DESTDIR="DIRECTORY TO BACKUP TO"
  9. DESTUSER="USER AT DESTINATION PC"
  10. HOMENET="NAME OF HOME NETWORK"
  11. LOCALADD="ADDRESS OF LOCAL COMPUTER (i.e. 192.168.1.4)"
  12. REMOTEADD="ADDRESS OF REMOTE COMPUTER(ie. thisis.mywebsite.com)"
  13.  
  14. ###Check what sort of network we're on
  15. echo "Checking network type..."
  16. sleep 1s
  17. LOCATION=`iwconfig | grep -c "$HOMENET"`
  18. if [ "$LOCATION" -ge "1" ]; then
  19.         echo "On the local network..."
  20.         nettype="local"
  21.         else
  22.         if [ "$LOCATION" -lt "1" ]; then
  23.                 echo "On a remote network..."
  24.                 nettype="remote"
  25.         fi
  26. fi
  27. echo ""
  28.  
  29. read -p "Is the above correct? (y/n) " correctness
  30. ###Switch network locations
  31. if [ "$correctness" = "n" ]; then
  32.         if [ "$nettype" = "local" ]; then
  33.                 nettype="remote"
  34.         fi
  35.         if [ "$nettype" = "remote" ]; then
  36.                 nettype="local"
  37.         fi
  38.         echo ""
  39.         echo "Switched network location to $nettype"
  40. fi
  41.  
  42. ###The local routine
  43. if [ "$nettype" = "local" ]; then
  44.         ssh -C -c blowfish $DESTUSER@$LOCALADD "mkdir $INCREMENTS"
  45.         rsync -acb --progress --exclude-from="$EXCLUDES" --backup-dir=$INCREMENTS -e "ssh -C -c blowfish" $SOURCEDIR $DESTUSER@$LOCALADD:$DESTDIR
  46. fi
  47.  
  48. ###The remote routine
  49. if [ "$nettype" = "remote" ]; then
  50.         ssh -C -c blowfish $DESTUSER@$REMOTEADD "mkdir $INCREMENTS"
  51.         rsync -acb --progress --exclude-from="$EXCLUDES" --backup-dir=$INCREMENTS -e "ssh -C -c blowfish" $SOURCEDIR $DESTUSER@$REMOTEADD:$DESTDIR
  52. fi
  53.  
  54. #end

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me