Automatic Backup Script

I want to crate a backup script which crate a backup each day
I want to store this on a stick in the FritzBox
I want to store the the Backups in special order
7 for one Day
4 for each week
12 for each month
Below my first step script for this
But I have a problem to mount the fritz stick to continue i need help.

Platform information:
Ip = 192.168.178.21
Release = Raspbian GNU/Linux 11 (bullseye)
Kernel = Linux 5.15.32-v7+
Platform = Raspberry Pi 3 Model B Rev 1.2
Uptime = 0 day(s). 20:58:49
CPU Usage = 0.25% avg over 4 cpu(s) (4 core(s) x 1 socket(s))
CPU Load = 1m: 0.16, 5m: 0.07, 15m: 0.02
Memory = Free: 0.12GB (13%), Used: 0.82GB (87%), Total: 0.95GB
Swap = Free: 2.25GB (98%), Used: 0.03GB (2%), Total: 2.29GB
Root = Free: 50.75GB (90%), Used: 5.10GB (10%), Total: 58.26GB
Updates = 0 apt updates available.
openHAB 3.3.0 - Release Build
openjdk 11.0.16 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Raspbian-1deb11u1)
OpenJDK Server VM (build 11.0.16+8-post-Raspbian-1deb11u1, mixed mode)

#! /bin/bash
# To use as cronjob daily 4:00am
# Variablen
Our_Mountpoint="/mnt/fritzNAS/Backup"
NoOfDaily=7
NoOfWeekly=4
NoOfMonthly=12

# Check Folder
if [ ! -d $Our_Mountpoint ] 
then
  cd /mnt/
  if [ ! -d $Our_Mountpoint ] 
  then
    mkdir fritzNAS
  fi
  cd fritzNAS
  mkdir Backup
fi
if [ ! -d $Our_Mountpoint ] 
then
  echo "Verzeichnis existiert nicht und konnte nicht erstelt werden" 
  exit 1
fi

# Check Mountpoint
if [ ! -d $Our_Mountpoint ] 
then
  mount -t cifs //192.168.178.1/FRITZ.NAS/files/Backup /mnt/fritzNAS/Backup -o username=XXXX,password=YYYY,uid=1000,gid=1000,rw,vers=1.0
fi
if [ ! -d $Our_Mountpoint ] 
then
  echo "Ziel konnte nicht eingebunden weden"
  exit 2
fi

# Check Subdir
if [ ! -d "${Our_mountpoint}/Daily/" ] 
then
  cd $Our_mountpoint
  mkdir Daily
fi
if [ ! -d "${Our_mountpoint}/Daily/" ] 
then
  echo "Daily-Verzeichnis existiert nicht und konnte nicht erstelt werden" 
  exit 3
fi
if [ ! -d "${Our_mountpoint}/Weekly/" ] 
then
  cd $Our_mountpoint
  mkdir Weekly
fi
if [ ! -d "${Our_mountpoint}/Weekly/" ] 
then
  echo "Weekly-Verzeichnis existiert nicht und konnte nicht erstelt werden" 
  exit 4
fi
if [ ! -d "${Our_mountpoint}/Monthly/" ] 
then
  cd $Our_mountpoint
  mkdir Monthly
fi
if [ ! -d "${Our_mountpoint}/Monthly/" ] 
then
  echo "Monthly-Verzeichnis existiert nicht und konnte nicht erstelt werden" 
  exit 5
fi

# Create Bachup
openhab-cli backup

# TODOs
# Check Backup Successfull
# Read Backup name
# Return from Backup Script:
# Success! Backup made in /var/lib/openhab/backups/openhab-backup-22_10_08-11_59_51.zip

# Daily special copy
cp $backupfile "${mountpoint}/Daily/"
# TODOs
# Remove the oldest Backups then more as NoOfDaily

# Weekly special copy
# FORMAT controls the output.  Interpreted sequences are:
#  %u   day of week (1..7); 1 is Monday
if [ date +%u = '1']
then 
  cp $backupfile "${mountpoint}/Weekly/"
fi
# TODOs
# Remove the oldest Backups then more as NoOfWeekly

# Monthly special Copy
# FORMAT controls the output.  Interpreted sequences are:
#  %d   day of month (e.g., 01)
if [ date +%d = '01']
then 
  cp $backupfile "${mountpoint}/Monthly/"
fi
# TODOs
# Remove the oldest Backups then more as NoOfMonthly

openhabian@openhabian:~ $ sudo umount /mnt/fritzNAS/Backup
umount: /mnt/fritzNAS/Backup: not mounted.
openhabian@openhabian:~ $ sudo mount -t cifs //192.168.178.1/FRITZ.NAS/files/Backup /mnt/fritzNAS/Backup -o username=XXXX,password=YYYY,uid=1000,gid=1000,rw,vers=1.0
mount error: cifs filesystem not supported by the system
mount error(19): No such device
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)

Why not using an existing, fully tested and working script, especially designed for Raspberry computers?

English version:

It does not make sense to export your config daily (that’s what openhab-cli does), or do you keep changing it every day ?
You would be ignoring everything else that might be worth backing up (such as persistence data).
Now since you already seem to be on openHABian, why not use what it’s offering you to ?
Amanda is there for data backup (yes you can mount any NAS drive like that from your Fritzbox).

Hi, raspiBackup looks realy good. I thing this ist what i need. But the mount problem ist still there.

Amanda looks good too.
I want only in the first time store only the config becouse i chance nerly every day and i want to restore wenn i have made a misstake for crash the system.

But later i want to store datas too

I feel really stupid right now I thought I had researched really well before I start to invent something new that others have actually used Thank you for these good suggestions.

I think I’ll try raspibackup first, I find the telegram notification particularly interesting here.

I need help with the MOUNT problem anyway, can help somebody

Nas in browser logged in with openhab user:

CIFS Support ist installed

openhabian@openhabian:~ $ sudo apt install samba cifs-utils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
cifs-utils is already the newest version (2:6.11-3.1+deb11u1).
samba is already the newest version (2:4.13.13+dfsg-1~deb11u4).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
openhabian@openhabian:~ $

openhabian@openhabian:~ $ sudo find / -name cifs
[sudo] password for openhabian:
find: ‘/proc/sys/fs/binfmt_misc’: No such device
find: ‘/proc/12147/task/20658’: No such file or directory
find: ‘/proc/12147/task/20667’: No such file or directory
/usr/lib/modules/5.15.61-v7l+/kernel/fs/cifs
/usr/lib/modules/5.15.61-v7+/kernel/fs/cifs
/usr/lib/modules/5.15.61-v8+/kernel/fs/cifs
/usr/lib/modules/5.15.61+/kernel/fs/cifs
/usr/include/linux/cifs
openhabian@openhabian:~ $ sudo lsmod | grep cifs
openhabian@openhabian:~ $ sudo modprobe -v -n cifs~
modprobe: FATAL: Module cifs~ not found in directory /lib/modules/5.15.32-v7+
openhabian@openhabian:~ $ uname -r
5.15.32-v7+
openhabian@openhabian:~ $

some times and (but no chances) some rebbot later

openhabian@openhabian:~ $ uname -r
5.15.61-v7+
openhabian@openhabian:~ $

i dont know whai but i have hade a Kernel <–> modules mismatch!