dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

backup (1148B)


      1 #!/bin/sh
      2 
      3 show_help() {
      4 	echo "usage: ${0##*/} [OPTIONS] TARGET"
      5 	echo "is a wrapper for rsync backing up /home and /etc to TARGET"
      6 	echo
      7 	echo "OPTIONS are one or more of the following:"
      8 	echo "   -h   show this message"
      9 	echo "   --   do not consider any following args as options"
     10 }
     11 
     12 die() {
     13 	printf '%s\n' "$1" >&2
     14 	exit 1
     15 }
     16 
     17 backup_home_etc() {
     18 	rsync -ravzhe ssh --delete /etc/ "$1"/etc/
     19 	rsync -ravzhe ssh --delete --progress \
     20 		--exclude=tmp \
     21 		--exclude=Downloads \
     22 		--exclude=.cache \
     23 		--exclude=videos/tmp \
     24 		--exclude=tags \
     25 		--exclude=.julia \
     26 		--exclude='.config/surf/cache' \
     27 		--exclude='.mail/.notmuch' \
     28 		--exclude='*.mbsyncstate' \
     29 		--exclude='*.uidvalidity' \
     30 		--exclude='*.core' \
     31 		~/ "$1"/home/ad/
     32 }
     33 
     34 while :; do
     35     case "$1" in
     36         -h)
     37             show_help
     38             exit 0
     39             ;;
     40         --) # end all options
     41             shift
     42             break
     43             ;;
     44         -?*)
     45             die 'error: Unknown option specified'
     46             ;;
     47         *)  # No more options
     48             break
     49     esac
     50     shift
     51 done
     52 
     53 if [ $# -lt 1 ]; then
     54     die 'error: no TARGET specified'
     55 fi
     56 
     57 backup_home_etc "$1"