Created
February 27, 2013 01:35
-
-
Save SteveRyherd/5044146 to your computer and use it in GitHub Desktop.
Bash script for synchronizing data from a directory to a WDTV or other external drive. -- NOTE: This script is asynchronous unlike the imgur drop script.
This file contains hidden or 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 | |
NET_DIR="//stevestv.local/portable" | |
TARGET_DIR="/media/wdtv" | |
SOURCE_DIR="/srv/wdtv/" #Include the trailing slash | |
# Exit upon errors | |
set -e | |
# Check if directory exists | |
if [ ! -d "$TARGET_DIR" ]; then | |
mkdir -p "$TARGET_DIR" | |
fi | |
# Check if mountpoint exists there | |
if ! mountpoint -q "$TARGET_DIR" ; then | |
echo "Mounting WDTV ... " | |
sudo mount -t cifs "$NET_DIR" "$TARGET_DIR" -o guest,rw,uid=1000,gid=1000,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 | |
fi | |
# Perform the syncronization | |
# Recursive, verbose, compress, preserve permissions, times, groups, etc | |
echo "Syncing Data ..." | |
rsync -rvzptgoD --copy-links --copy-dirlinks "$SOURCE_DIR" "$TARGET_DIR" | |
echo "Syncronization Finished." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment