Synology NAS – Ordner als 7zip Datei und Passwort auf USB sichern

#!/bin/bash

backup_dir="/volumeUSB1/usbshare1/backup365"
current_date=$(date +"%Y-%m-%d")
older_than_days=6
zip_password="12345"

# Erstellen des 7zip-Archivs mit Passwort
backup_archive="backup365_$current_date.7z"
7z a -p"$zip_password" "$backup_dir/$backup_archive" /volume1/ActiveBackupforBusiness/ActiveBackupForMicrosoft365

# Löschen älterer Archive
find "$backup_dir" -name 'backup365_*.7z' -type f -mtime +$older_than_days -exec rm {} \;

# Kopieren neuer Archive
find "$backup_dir" -name 'backup365_*.7z' -type f -newer "$backup_dir$backup_archive" -exec cp {} /destination/path/ \;

# Überprüfen und Kopieren neuer Archive
if [ -f "$backup_dir$backup_archive" ]; then
    for file in "$backup_dir"backup365_*.7z; do
        if [ "$file" -nt "$backup_dir$backup_archive" ]; then
            cp -f "$file" /destination/path/
        fi
    done
fi

SUCHWORTE:

Lasse gerne ein Kommentar da, vielleicht hilft es auch anderen Usern?

WiKi.Premium-Lizenz.com
Logo
Jetzt registrieren