Skip to content

Commit

Permalink
update configs; zfs
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
  • Loading branch information
ehazlett committed Dec 13, 2019
1 parent f24ce82 commit ec447f4
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion alacritty.yml
Expand Up @@ -148,7 +148,7 @@ font:
#style: Bold Italic

# Point size
size: 7.0
size: 7.5

# Offset is the extra space around each character. `offset.y` can be thought of
# as modifying the line spacing, and `offset.x` as modifying the letter spacing.
Expand Down
2 changes: 1 addition & 1 deletion linux/i3config
Expand Up @@ -203,7 +203,7 @@ bindsym $mod+Control+Shift+k focus parent, kill
#exec xfce4-power-manager &
exec feh --bg-scale ~/.wallpaper

exec xautolock -time 5 -locker ~/.dotfiles/linux/lock.sh &
exec xautolock -time 5 -locker ~/.dotfiles/linux/lock.sh -detectsleep &

# touchpad
exec ~/.dotfiles/scripts/touchpad.sh
2 changes: 1 addition & 1 deletion linux/swayconfig
Expand Up @@ -257,7 +257,7 @@ bar {

# When the status_command prints a new line to stdout, swaybar updates.
# The default just shows the current date and time.
status_command while ~/.dotfiles/swaystatus; do sleep 1; done
status_command i3status -c ~/.dotfiles/linux/i3status.conf

colors {
statusline #ffffff
Expand Down
1 change: 0 additions & 1 deletion scripts/backup.sh
@@ -1,6 +1,5 @@
#!/bin/bash
VOLS="tank/chroot/underland tank/chroot/work tank/containerd tank/home tank/iso tank/packages tank/root/terra"
DEST=${DEST:-/mnt/backup}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

VOLS=$VOLS DEST=$DEST $SCRIPT_DIR/zfs-backup.sh
Expand Down
35 changes: 22 additions & 13 deletions scripts/zfs-backup.sh
@@ -1,4 +1,5 @@
#!/bin/bash
set +e
VOLS=${VOLS:-}
DEST=${DEST:-}
SNAP=${SNAP:-"$(date +%Y%m%d-%H%M)"}
Expand All @@ -8,20 +9,28 @@ if [ -z "$VOLS" ]; then
exit 1
fi

if [ -z "$DEST" ]; then
echo "DEST env var must be specified"
exit 1
fi

echo " -> starting backup for $SNAP"
mkdir -p $DEST/$SNAP

zfs list $VOLS > $DEST/$SNAP/zfs-vols

for vol in $VOLS; do
echo " -> $vol"
zfs snap $vol@$SNAP
target=$(echo $vol | tr '/', '_')
zfs send $vol@$SNAP > $DEST/$SNAP/$target
zfs destroy $vol@$SNAP
# skip mirror if DEST is missing
if [ -z "$DEST" ]; then
continue
fi
base=$(echo $vol | cut -d'/' -f1)
target="$DEST/$vol"
zfs list -H $(dirname $target) > /dev/null
if [ $? -ne 0 ]; then
zfs create -p $(dirname $target)
fi
# check for existing snaps
target_snaps=$(zfs list -H -t snap $target > /dev/null)
if [ $? -eq 0 ]; then
snaps="$(zfs list -H -t snap $vol)"
# snap incremental
oldest=$(echo $snaps | head -1 | awk '{ print $1; }' | cut -d'@' -f2)
zfs send -RI $vol@$oldest $vol@$SNAP | zfs recv -Fu $target
else
# full
zfs send -R $vol@$SNAP | zfs recv -Fu $target
fi
done
16 changes: 16 additions & 0 deletions scripts/zfs-prune.sh
@@ -0,0 +1,16 @@
#!/bin/bash
set +e
KEEP=${KEEP:-5}
VOLS=${VOLS:-"$(zfs list -H | awk '{ print $1; }')"}

for vol in $VOLS; do
snaps=($(zfs list -H -t snap $vol | awk '{ print $1; }'))
if [ $? -eq 0 ]; then
num=${#snaps[@]}
# always keep the first
for (( i=1; i<=$(( $num - $KEEP-1 )); i++ )); do
echo " -> removing ${snaps[$i]}"
zfs destroy ${snaps[$i]}
done
fi
done

0 comments on commit ec447f4

Please sign in to comment.