|
|
@ -1,12 +1,6 @@ |
|
|
|
#!/bin/bash -e |
|
|
|
#!/bin/bash -e |
|
|
|
|
|
|
|
|
|
|
|
if test -e /etc/btrfs-snapshot.conf; then |
|
|
|
# defaults |
|
|
|
. /etc/btrfs-snapshot.conf |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
if test -e ~/.btrfs-snapshot; then |
|
|
|
|
|
|
|
. ~/.btrfs-snapshot |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HOURLY_DEL=25 |
|
|
|
HOURLY_DEL=25 |
|
|
|
DAILY_DEL=8 |
|
|
|
DAILY_DEL=8 |
|
|
|
WEEKLY_DEL=5 |
|
|
|
WEEKLY_DEL=5 |
|
|
@ -14,6 +8,15 @@ MONTHLY_DEL= |
|
|
|
BTRFS_VOLUMES=${BTRFS_VOLUMES:-$(awk '!/^#/ && $3=="btrfs" {print $2}' /etc/fstab | tr '\n' ' ' | sed 's, $,,')} |
|
|
|
BTRFS_VOLUMES=${BTRFS_VOLUMES:-$(awk '!/^#/ && $3=="btrfs" {print $2}' /etc/fstab | tr '\n' ' ' | sed 's, $,,')} |
|
|
|
TMP_MNT=${TMP_MNT:-/var/tmp/btrfs-backup} |
|
|
|
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=() |
|
|
|
vols=() |
|
|
|
del=${DEL} |
|
|
|
del=${DEL} |
|
|
|
dryrun=0 |
|
|
|
dryrun=0 |
|
|
@ -144,7 +147,9 @@ for fs in ${BTRFS_VOLUMES}; do |
|
|
|
fi |
|
|
|
fi |
|
|
|
sudo umount "$TMP_MNT" |
|
|
|
sudo umount "$TMP_MNT" |
|
|
|
if test $fast -eq 0; then |
|
|
|
if test $fast -eq 0; then |
|
|
|
|
|
|
|
echo "Defragment subvolume: '${fs}'" |
|
|
|
sudo btrfs filesystem defragment ${fs} |
|
|
|
sudo btrfs filesystem defragment ${fs} |
|
|
|
|
|
|
|
echo "Rebalance subvolume: '${fs}'" |
|
|
|
sudo btrfs balance start ${fs} |
|
|
|
sudo btrfs balance start ${fs} |
|
|
|
fi |
|
|
|
fi |
|
|
|
else |
|
|
|
else |
|
|
|