Backup backing up backup - out of disk space

TL:DR - the backup storage is getting backuped

My openhab setup has been experiencing some strange behaviour. There are errors in my logs about ‘out of disk space’ but when I check there is 62% use (5.3gb available) running openhabian.

I wondered about the backup and found this crontab:

cat /etc/openhab2/scripts/backup.sh

#!/usr/bin/env bash

#####################################################

# Date with Timestamp

#####################################################

echo "+-+-+-+-+-+-+ Set Timestamp +-+-+-+-+-+-+-+-+"

DATE=`date +%Y_%m_%d-%H_%M_%S`

#####################################################

# Backup openHAB

#####################################################

echo "+-+-+-+-+-+-+ openHAB Backup +-+-+-+-+-+-+-+-+"

openhab-cli backup

############################################

# Rsync

############################################

# vim: filetype=sh

I ran the backup command in here and sure enough the disk size got really small. Investigated and found that the previous backups where being included in the backup…:

**[07:01:08]** **root@openhab2** : **/tmp** # cd openhab2/

**[07:01:19]** **root@openhab2** : **/tmp/openhab2** # ls

**backup**

**[07:01:20]** **root@openhab2** : **/tmp/openhab2** # cd backup/

**[07:01:23]** **root@openhab2** : **/tmp/openhab2/backup** # ls

backup.properties **userdata**

**[07:01:24]** **root@openhab2** : **/tmp/openhab2/backup** # du -h

1.2M ./userdata/backups/openhab1

2.9G ./userdata/backups

2.9G ./userdata

2.9G .

The question is, is this my doing and how do I fix it?

I just cleared out all the old backups and freed 7GB.

You need to change the back-up destination folder to a folder that is not included in the back-up

For example:
sudo ./runtime/bin/backup ~/backups/myconfig.zip ## Creates a backup file in the specified location.