Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/sh
- set -e
- cd "/$1"
- LAST=$(ls -t | grep -m 1 -P '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$' || echo .)
- TIME=$(date +"%F %T")
- mkdir "/$1/$TIME"
- for DIR in $(grep -v "^#" backup.dirs)
- do
- EXCLUDE="/$1/$DIR.exclude"
- [ -f "$EXCLUDE" ] || touch "$EXCLUDE"
- rsync \
- --recursive \
- --delete \
- --delete-excluded \
- --archive \
- --acls \
- --hard-links \
- --xattrs \
- --numeric-ids \
- --sparse \
- --bwlimit=10000 \
- --exclude-from="$EXCLUDE" \
- --link-dest="/$1/$LAST" \
- --verbose \
- "$2//$DIR" "/$1/$TIME" \
- > "/$1/$TIME/$DIR.log" 2>&1 || :
- done
- find "/$1" -maxdepth 1 -name "????-??-?? ??:??:??" -type d -ctime +30 | sort | head -n -7 | perl -lne 'print quotemeta' | xargs rm -rf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement