Skip to content

Instantly share code, notes, and snippets.

@noxqsgit
Last active December 13, 2015 21:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noxqsgit/4978397 to your computer and use it in GitHub Desktop.
Save noxqsgit/4978397 to your computer and use it in GitHub Desktop.
sync
#!/bin/bash
host="$HOSTNAME"
exclude_list=(
/.bundle /.cabal /.gem /.node /.npm /.vagrant.d /Downloads /VMs
/opt/{pkg,src} /tmp/work/dump
)
for x in "$HOME"/tmp/build/chromium*; do
exclude_list+=( "${x:${#HOME}}" )
done
exclude_ignore=(
/.cache /.local/share/Trash /.m2 /.thumbnails
)
# --
excl=()
for e in "${exclude_list[@]}" "${exclude_ignore[@]}"; do
excl+=( --exclude "$e" )
done
# --
[ ! -e "$host"-home ] && mkdir "$host"-home
rsync -a -v --progress --delete "${excl[@]}" "$HOME"/ "$host"-home/
echo
# --
for e in "${exclude_list[@]}"; do
echo "(listing $e ...)" >&2
find "$HOME/$e"
done | sort > "$host"-home-excl-list
echo done.
# --
#!/bin/bash
dirs=( /etc /root /var/log )
for d in "${dirs[@]}"; do
f="sys${d//\//-}.tar"
cmd=( tar cf "$f" "$d" )
echo "$ ${cmd[@]}"
touch "$f"
sudo "${cmd[@]}"
chmod 400 "$f"
echo
done
# --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment