Created
November 6, 2011 10:40
-
-
Save stanwu/1342741 to your computer and use it in GitHub Desktop.
rsync_usb.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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