SHARE
TWEET

Untitled

a guest May 24th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/sh
  2.  
  3. set -e
  4.  
  5.  
  6. cd "/$1"
  7.  
  8. LAST=$(ls -t | grep -m 1 -P '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$' || echo .)
  9.  
  10.  
  11. TIME=$(date +"%F %T")
  12. mkdir "/$1/$TIME"
  13.  
  14.  
  15. for DIR in $(grep -v "^#" backup.dirs)
  16. do
  17.     EXCLUDE="/$1/$DIR.exclude"
  18.     [ -f "$EXCLUDE" ]  ||  touch "$EXCLUDE"
  19.  
  20.     rsync \
  21.         --recursive \
  22.         --delete \
  23.         --delete-excluded \
  24.         --archive \
  25.         --acls \
  26.         --hard-links \
  27.         --xattrs \
  28.         --numeric-ids \
  29.         --sparse \
  30.         --bwlimit=10000 \
  31.         --exclude-from="$EXCLUDE" \
  32.         --link-dest="/$1/$LAST" \
  33.         --verbose \
  34.         "$2//$DIR" "/$1/$TIME" \
  35.         > "/$1/$TIME/$DIR.log" 2>&1 || :
  36. done
  37.  
  38.  
  39. find "/$1" -maxdepth 1 -name "????-??-?? ??:??:??" -type d -ctime +30 | sort | head -n -7 | perl -lne 'print quotemeta' | xargs rm -rf
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top