minor fixes

This commit is contained in:
snaki 2022-05-30 13:13:59 +02:00
parent 5f253533e4
commit 5292c9d434

16
btrbk
View file

@ -3,9 +3,9 @@
source config.sh source config.sh
startDate=$(date +%s) startDate=$(date +%s)
function main { function bkRun {
date=$(date +%Y-%m-%d) local date=$(date +%Y-%m-%d)
month=$(date +%Y-%B) local month=$(date +%Y-%B)
for i in ${!SUBVOLS[@]}; do for i in ${!SUBVOLS[@]}; do
snapName=${VOLNAME[$i]}.$date snapName=${VOLNAME[$i]}.$date
snapLast=$SNAPDIR${VOLNAME[$i]}.$(date -d "$date -1 day" +%Y-%m-%d) snapLast=$SNAPDIR${VOLNAME[$i]}.$(date -d "$date -1 day" +%Y-%m-%d)
@ -18,11 +18,11 @@ function main {
else else
btrfs subvolume snapshot -r ${SUBVOLS[$i]} $SNAPDIR$snapName btrfs subvolume snapshot -r ${SUBVOLS[$i]} $SNAPDIR$snapName
fi fi
if [[ -d "$snapLast" && $bkType = "daily" ]]; then if [[ -d "$snapLast" && $1 = "daily" ]]; then
btrfs send -p $snapLast $SNAPDIR$snapName | gpg --batch -er $PUBKEY -o - | rclone rcat $RCLONEDIR$month"-incr/"$snapName.pgp btrfs send -p $snapLast $SNAPDIR$snapName | gpg --batch -er $PUBKEY -o - | rclone rcat $RCLONEDIR$month"-incr/"$snapName.pgp
else else
btrfs send $SNAPDIR$snapName | gpg --batch -er $PUBKEY -o - | rclone rcat $RCLONEDIR$month"-full/"$snapName.pgp btrfs send $SNAPDIR$snapName | gpg --batch -er $PUBKEY -o - | rclone rcat $RCLONEDIR$month"-full/"$snapName.pgp
if [[ $bktype = monthly ]] && rclone ls $RCLONEDIR$(date -d "$date -1 month" +%Y-%B)-incr; then if [[ $1 = "monthly" ]] && rclone ls $RCLONEDIR$(date -d "$date -1 month" +%Y-%B)-incr; then
rclone delete $RCLONEDIR$(date -d "$date -1 month" +%Y-%B)-incr/ rclone delete $RCLONEDIR$(date -d "$date -1 month" +%Y-%B)-incr/
if rclone ls $RCLONEDIR$(date -d "$date -6 month" +%Y-%B)-full/; then if rclone ls $RCLONEDIR$(date -d "$date -6 month" +%Y-%B)-full/; then
rclone delete $RCLONEDIR$(date -d "$date -6 month" +%Y-%B)-full/ rclone delete $RCLONEDIR$(date -d "$date -6 month" +%Y-%B)-full/
@ -39,11 +39,9 @@ function main {
function testDate { function testDate {
if [ `date +%d` != "01" ]; then if [ `date +%d` != "01" ]; then
bkType=daily bkRun "daily"
main
else else
bkType=monthly bkRun "monthly"
main
fi fi
} }