Advertisement
Guest User

Untitled

a guest
May 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.82 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement