From 5ec9d1f164b099b36cdcc08f292d44bc33284044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marc=20W=C3=A4ckerlin?= Date: Fri, 27 Oct 2017 10:33:23 +0200 Subject: [PATCH] fixed loading of configuration files --- btrfs-snapshots.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/btrfs-snapshots.sh b/btrfs-snapshots.sh index 302be0d..0dff4a4 100755 --- a/btrfs-snapshots.sh +++ b/btrfs-snapshots.sh @@ -1,12 +1,6 @@ #!/bin/bash -e -if test -e /etc/btrfs-snapshot.conf; then - . /etc/btrfs-snapshot.conf -fi -if test -e ~/.btrfs-snapshot; then - . ~/.btrfs-snapshot -fi - +# defaults HOURLY_DEL=25 DAILY_DEL=8 WEEKLY_DEL=5 @@ -14,6 +8,15 @@ MONTHLY_DEL= BTRFS_VOLUMES=${BTRFS_VOLUMES:-$(awk '!/^#/ && $3=="btrfs" {print $2}' /etc/fstab | tr '\n' ' ' | sed 's, $,,')} TMP_MNT=${TMP_MNT:-/var/tmp/btrfs-backup} +# overwrite defaults in configs +if test -e /etc/btrfs-snapshots.conf; then + . /etc/btrfs-snapshots.conf +fi +if test -e ~/.btrfs-snapshots; then + . ~/.btrfs-snapshots +fi + +# evaluate commandline vols=() del=${DEL} dryrun=0 @@ -144,7 +147,9 @@ for fs in ${BTRFS_VOLUMES}; do fi sudo umount "$TMP_MNT" if test $fast -eq 0; then + echo "Defragment subvolume: '${fs}'" sudo btrfs filesystem defragment ${fs} + echo "Rebalance subvolume: '${fs}'" sudo btrfs balance start ${fs} fi else