Skip to content

Instantly share code, notes, and snippets.

@bendem
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bendem/6b7881ee1057707371ee to your computer and use it in GitHub Desktop.
Save bendem/6b7881ee1057707371ee to your computer and use it in GitHub Desktop.
mount="/home/bendem/nas-samba"
d=`date +"%H:%M:%S %d-%m-%Y"`
echo "Backup task running $d"
# Skip if not mounted
grep -qs "$mount" /proc/mounts
if [ $? -ne 0 ]; then
echo "Skipping..."
exit
fi
source="${1%%/}/"
target="${2##/}"
target="${target%%/}"
target="$mount/Backups/$target/"
mkdir -p "$target"
rsync -av "$source" "$target" \
--no-group \
--no-owner \
--no-perms \
--safe-links \
--exclude '.git/' \
--exclude 'bin/' \
--exclude 'target/' \
--exclude 'vendor/' \
--exclude 'build/' \
--exclude 'dist/' \
--exclude 'vagrant/' \
--exclude 'out/' \
--exclude 'obj/' \
--exclude '_site/' \
--exclude '.idea/' \
--exclude 'cache/' \
--exclude 'CMakeFiles/' \
--exclude 'node_modules/' \
--exclude 'autom4te.cache/' \
--exclude 'wp-content/uploads/' \
--exclude '*.vcxproj.filters' \
--exclude '*.pyc' \
--exclude '*.class' \
--exclude '*.so' \
--exclude '*.exe' \
--exclude '*.o'
if [ -d "$mount/recycle/" ]; then
echo "Removing trash"
rm -r "$mount/recycle/"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment