I have created a bash script that creates incremental backups every hour, it is called via crontab. This script works flawlessly and only takes about a few minutes to run every time.
The issue is that I have in the beginning of the script a conditional that lets me disable backups temporarily except for the one at 5 am, simply by creating an empty file 'backup.disabled'.
Nothing else can create these directories here except this backup script, and of course the backup script does not backup it's own backups, and I confirmed that they only take about 1-5 minutes to run every time, from one NVME drive to another.
The conditional does not seem to work correctly, although it is pretty basic.
# Do not run the backup if the file 'backup.disabled' exists and it is not currently 5 am.
if [[ -e backup.disabled && "`date +%H`" -ne "05" ]] ; then
exit
fi
# Start the backup
BACKUP_DIR_NAME="`date +%F_%H%M`"
#.... everything after this works perfectly, no need to show it
Here are the resulting backup directories after creating 'backup.disabled' on Oct 13 around 21:30 :
#...
drwxr-xr-x 1 root root 34 Oct 13 07:05 2020-10-13_0700
drwxr-xr-x 1 root root 34 Oct 13 08:03 2020-10-13_0800
drwxr-xr-x 1 root root 34 Oct 13 09:02 2020-10-13_0900
drwxr-xr-x 1 root root 34 Oct 13 10:02 2020-10-13_1000
drwxr-xr-x 1 root root 34 Oct 13 11:01 2020-10-13_1100
drwxr-xr-x 1 root root 34 Oct 13 12:01 2020-10-13_1200
drwxr-xr-x 1 root root 34 Oct 13 13:02 2020-10-13_1300
drwxr-xr-x 1 root root 34 Oct 13 14:04 2020-10-13_1400
drwxr-xr-x 1 root root 34 Oct 13 15:01 2020-10-13_1500
drwxr-xr-x 1 root root 34 Oct 13 16:01 2020-10-13_1600
drwxr-xr-x 1 root root 34 Oct 13 17:04 2020-10-13_1700
drwxr-xr-x 1 root root 34 Oct 13 18:06 2020-10-13_1800
drwxr-xr-x 1 root root 34 Oct 13 19:03 2020-10-13_1900
drwxr-xr-x 1 root root 34 Oct 13 20:01 2020-10-13_2000
drwxr-xr-x 1 root root 34 Oct 13 21:01 2020-10-13_2100
# at this point I created 'backup.disabled'
drwxr-xr-x 1 root root 34 Oct 14 05:05 2020-10-14_0500
drwxr-xr-x 1 root root 34 Oct 14 08:01 2020-10-14_0800
drwxr-xr-x 1 root root 34 Oct 14 09:02 2020-10-14_0900
drwxr-xr-x 1 root root 34 Oct 15 05:01 2020-10-15_0500
drwxr-xr-x 1 root root 34 Oct 15 08:00 2020-10-15_0800
drwxr-xr-x 1 root root 34 Oct 15 09:00 2020-10-15_0900
The issue: It turns out that it creates the backup at 5 am, 8 am and 9 am... but it's only supposed to create the one at 5 am when the file 'backup.disabled' exists, unless I am missing something ???
The backups at 8 and 9 am all seem to be very normal backups...
Either way I find this issue very weird and would like to understand what is happening.
Thank you.