Last active
August 29, 2015 14:19
-
-
Save bendem/6b7881ee1057707371ee to your computer and use it in GitHub Desktop.
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
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