Skip to content

Instantly share code, notes, and snippets.

@noxqsgit noxqsgit/sync-home
Last active Dec 13, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.