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)