Posted by jmbarnes on Thu 19th Aug 15:28 (modification of post by jmbarnes view diff)
diff | download | new post
- #/bin/bash
- ###
- ###Variables
- BACKUPTIME="`date +%m_%d_%Y`"
- INCREMENTS="PATH TO INCREMENTS/$BACKUPTIME"
- EXCLUDES="TEXT FILE OF THINGS TO EXCLUDE"
- SOURCEDIR="DIRECTORY TO BACKUP"
- DESTDIR="DIRECTORY TO BACKUP TO"
- DESTUSER="USER AT DESTINATION PC"
- HOMENET="NAME OF HOME NETWORK"
- LOCALADD="ADDRESS OF LOCAL COMPUTER (i.e. 192.168.1.4)"
- REMOTEADD="ADDRESS OF REMOTE COMPUTER(ie. thisis.mywebsite.com)"
- ###Check what sort of network we're on
- echo "Checking network type..."
- sleep 1s
- LOCATION=`iwconfig | grep -c "$HOMENET"`
- if [ "$LOCATION" -ge "1" ]; then
- echo "On the local network..."
- nettype="local"
- else
- if [ "$LOCATION" -lt "1" ]; then
- echo "On a remote network..."
- nettype="remote"
- fi
- fi
- echo ""
- read -p "Is the above correct? (y/n) " correctness
- ###Switch network locations
- if [ "$correctness" = "n" ]; then
- if [ "$nettype" = "local" ]; then
- nettype="remote"
- fi
- if [ "$nettype" = "remote" ]; then
- nettype="local"
- fi
- echo ""
- echo "Switched network location to $nettype"
- fi
- ###The local routine
- if [ "$nettype" = "local" ]; then
- ssh -C -c blowfish $DESTUSER@$LOCALADD "mkdir $INCREMENTS"
- rsync -acb --progress --exclude-from="$EXCLUDES" --backup-dir=$INCREMENTS -e "ssh -C -c blowfish" $SOURCEDIR $DESTUSER@$LOCALADD:$DESTDIR
- fi
- ###The remote routine
- if [ "$nettype" = "remote" ]; then
- ssh -C -c blowfish $DESTUSER@$REMOTEADD "mkdir $INCREMENTS"
- rsync -acb --progress --exclude-from="$EXCLUDES" --backup-dir=$INCREMENTS -e "ssh -C -c blowfish" $SOURCEDIR $DESTUSER@$REMOTEADD:$DESTDIR
- fi
- #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.