Last active
August 29, 2015 14:05
-
-
Save omerucel/b4ca5ddadb30a147a346 to your computer and use it in GitHub Desktop.
backup & recovery script
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 | |
CURRENT_DIR=$(date +"%Y-%m-%d-%H-%M-%S") | |
ROOT=/media/omer/YEDEK/backup/$CURRENT_DIR | |
PATHS=() | |
PATHS+=(/home/omer/AndroidKeys) | |
PATHS+=(/home/omer/AndroidProjects) | |
PATHS+=(/home/omer/Apps) | |
PATHS+=(/home/omer/Documents) | |
PATHS+=(/home/omer/Music) | |
PATHS+=(/home/omer/Pictures) | |
PATHS+=(/home/omer/Projects) | |
mkdir -p $ROOT | |
for item in ${PATHS[*]} | |
do | |
rsync -azv $item $ROOT | |
done |
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 | |
ROOT=/media/omer/YEDEK/backup/ | |
DIRS=() | |
for FILE in $ROOT*; do | |
[[ -d $FILE ]] && DIRS+=($FILE) | |
done | |
for i in "${!DIRS[@]}"; do | |
printf "%s\t%s\n" "$i" "${DIRS[$i]}" | |
done | |
read -p "Please enter recovery directory: " DIRECTORY_INDEX | |
echo "You selected directory to recovery: ${DIRS[$DIRECTORY_INDEX]}" | |
read -p "Are you sure? (y/n) " RESP | |
if [ "$RESP" = "y" ]; then | |
read -p "Please enter a location to save the files:" LOCAL_DIRECTORY | |
echo "Files will be saved in the following location: $LOCAL_DIRECTORY" | |
read -p "Are you sure? (y/n) " RESP | |
if [ "$RESP" = "y" ]; then | |
mkdir -p $LOCAL_DIRECTORY | |
rsync -azv ${DIRS[$DIRECTORY_INDEX]}/ $LOCAL_DIRECTORY | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment