Skip to content

Instantly share code, notes, and snippets.

@stanwu
Created November 6, 2011 10:40
Show Gist options
  • Save stanwu/1342741 to your computer and use it in GitHub Desktop.
Save stanwu/1342741 to your computer and use it in GitHub Desktop.
rsync_usb.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 [backup/restore]"
exit
fi
mydir=`dirname $1`
mybase=`basename $1`
mypath="$mydir/$mybase"
#echo $mypath
if [ "$1" == "backup" ]; then
if [ -d /usr/src/xxx/home/xxx/2.2.1 ]; then
mkdir -p src
rsync -avuz --progress --delete --exclude '.*' /usr/src/xxx/home/xxx/ src
else
echo "/usr/src/xxx/home/xxx not found!"
exit
fi
fi
if [ "$1" == "restore" ]; then
if [ -d src/2.2.1 ]; then
if [ -d /usr/src/xxx/home/xxx ]; then
rsync -avuz --progress --delete --exclude '.*' src/ /usr/src/xxx/home/xxx
else
echo "/usr/src/xxx/home/xxx not found!"
exit
fi
else
echo "I can not found the source folder"
exit
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment