Benutzer-Werkzeuge

Webseiten-Werkzeuge


know-how:backup

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
know-how:backup [2019/10/22 09:35] – [rsnapshot] ccknow-how:backup [2024/02/26 10:31] (aktuell) cc
Zeile 1: Zeile 1:
 +~~ODT~~
 +====== Prinzipien ======
 +  * Generelle Punkte unabhängig von der eingesetzten Lösung
 +  * Diese Fragen sind essentiell für eine funktionierende Backup/Restore Lösung
 +
 +  * Hast du eine Backup Lösung ? 
 +  * Wurde definiert welche Daten das Backup beinhalten soll ?
 +  * Werden bestimmte Zustände deiner Daten zu bestimmten Zeitpunkten festgehalten ?
 +  * Wurde definiert wie lange bestimmte Zustände für ein Restore verfügbar sein müssen ?
 +  * Gibt es gesetzliche Verpflichtungen für die Dauer der Aufbewahrung und Qualität der Backups ?
 +  * Wo liegen die Backup Daten physikalisch ?
 +  * Wie wird der Raum in dem sich die Daten physikalisch befinden gesichert ?
 +  * Sind die Daten gegen Diebstahl / Blitzschlag / Überschwemmungen gesichert ?
 +  * Was passiert bei Ereignissen **"höherer Gewalt"** ?
 +  * Gibt es zumindest einen 2. Standort deiner Backup Daten ?
 +  * Ist es möglich die Integrität des Backups zu überprüfen ?
 +  * Wurde schon einmal ein Restore durchgeführt ? 
 +  * Kannst du selbstständig einen Restore durchführen ?
 +  * Wie lange hat der Restore gedauert ?
 +  * Welche Softwarelösungen zB: Betriebssystem / Basis werden für den Restore benötigt ?
 +  * Welche Lizenzen werden benötigt um einen Restore durchzuführen ?
 +
 +
 ====== Windows ====== ====== Windows ======
   * Windows Sicherung muss installiert sein   * Windows Sicherung muss installiert sein
   * Generiert VHDX Datein die gemountet werden können   * Generiert VHDX Datein die gemountet werden können
 +
 +
  
 ===== Externer SAMBA Server rotierend ===== ===== Externer SAMBA Server rotierend =====
Zeile 86: Zeile 111:
 exit exit
 </code> </code>
 +
  
 ===== Hyper-V Guests auf Festplatte rotierend ===== ===== Hyper-V Guests auf Festplatte rotierend =====
Zeile 114: Zeile 140:
 echo "----END BACKUP----" >> %LOGFILE% echo "----END BACKUP----" >> %LOGFILE%
 </code> </code>
 +
 +
 +===== Restore mit Windows Boardmitteln =====
 +  * Über zB: Windows 10 iso / reparieren / System Image wiederherstellen / Im Netzwerk suchen
 +  * Windows kann grundsätzlich vhdx Dateien als virtuelle Datenträger einbinden zB: über die "Computerverwaltung" -> "Datenträger" -> rechts anfügen vhd(x) - auch UNC Pfade auf Samba Server sind möglich (getestet mit Debian 10 / Windows 10 FIXME
 +  * **Achtung**
 +     * BIOS/UEFI beachten 
 +     * Ziel Datenträger muss mindestens gleich groß /größer sein (think thin Provisioning für restore)
 +     * Format für die Eingabe von Benutzername: IP\BENUTZERNAME (wenn Daten auf samba Share liegen)
  
 ===== Duplicati 2 - verschlüsseltes Cloud Backup ===== ===== Duplicati 2 - verschlüsseltes Cloud Backup =====
Zeile 132: Zeile 167:
  
   * Wiederherstellung von einzelnen Dateien hat beim Testen funktioniert war jedoch **sehr** langsam    * Wiederherstellung von einzelnen Dateien hat beim Testen funktioniert war jedoch **sehr** langsam 
 +
 +===== Urbackup =====
 +  * https://www.urbackup.org/download.html
 +
 +  * Fehler Referenzmaschine war "Hyper-V" Client und wurde auf physikalische Maschine migriert - Fehlermeldung am Client  ** "Hyper-V IC Software Shadow Copy Provider ist noch installiert ** 
 +<code>
 +2019-11-06 06:31:52: ERROR: Not found
 +2019-11-06 06:31:56: ERROR: backupcom->AddToSnapshotSet(&(Server->ConvertToWchar(selected_vols[i])[0]), GUID_NULL, &additional_refs[i].volid) failed. VSS error code VSS_E_UNEXPECTED_PROVIDER_ERROR
 +2019-11-06 06:31:56: ERROR: VSS provider information:
 +2019-11-06 06:31:56: ERROR: Anbietername: "Hyper-V IC Software Shadow Copy Provider"
 +2019-11-06 06:31:56: ERROR: Anbietertyp: Software
 +2019-11-06 06:31:56: ERROR: Anbieterkennung: {74600e39-7dc5-4567-a03b-f091d6c7b092}
 +2019-11-06 06:31:56: ERROR: Version: 1.0.0.0
 +2019-11-06 06:31:56: ERROR: Anbietername: "Microsoft Software Shadow Copy provider 1.0"
 +2019-11-06 06:31:56: ERROR: Anbietertyp: System
 +2019-11-06 06:31:56: ERROR: Anbieterkennung: {b5946137-7b9f-4925-af80-51abd60b20d5}
 +2019-11-06 06:31:56: ERROR: Version: 1.0.0.7
 +2019-11-06 06:31:56: ERROR: Creating shadowcopy of "C:" failed.
 +2019-11-06 06:31:56: ERROR: Creating shadow copy failed. See client log file for details.
 +2019-11-06 07:12:01: ERROR: Not found
 +2019-11-06 07:12:03: ERROR: backupcom->AddToSnapshotSet(&(Server->ConvertToWchar(selected_vols[i])[0]), GUID_NULL, &additional_refs[i].volid) failed. VSS error code VSS_E_UNEXPECTED_PROVIDER_ERROR
 +2019-11-06 07:12:03: ERROR: VSS provider information:
 +2019-11-06 07:12:03: ERROR: Anbietername: "Hyper-V IC Software Shadow Copy Provider"
 +2019-11-06 07:12:03: ERROR: Anbietertyp: Software
 +2019-11-06 07:12:03: ERROR: Anbieterkennung: {74600e39-7dc5-4567-a03b-f091d6c7b092}
 +2019-11-06 07:12:03: ERROR: Version: 1.0.0.0
 +2019-11-06 07:12:03: ERROR: Anbietername: "Microsoft Software Shadow Copy provider 1.0"
 +2019-11-06 07:12:03: ERROR: Anbietertyp: System
 +2019-11-06 07:12:03: ERROR: Anbieterkennung: {b5946137-7b9f-4925-af80-51abd60b20d5}
 +2019-11-06 07:12:03: ERROR: Version: 1.0.0.7
 +2019-11-06 07:12:03: ERROR: Creating shadowcopy of "C:" failed.
 +2019-11-06 07:12:03: ERROR: Creating shadow copy failed. See client log file for details.
 +
 +</code>
 +
 +  * **Lösung**: Provider löschen (https://social.technet.microsoft.com/Forums/ie/en-US/ba9e020e-bbed-446a-be37-40cb00cd908d/manually-uninstall-integration-services-without-hyperv?forum=winserverhyperv ) 
 +<code>
 +[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS\Providers\{74600e39-7dc5-4567-a03b-f091d6c7b092}] 
 +
 +"vssadmin list providers" sollte nach einem Reboot den Hyper V Provider nicht mehr anzeigen
 +</code>
 +
 +  * Bei der ISO Datei für den **Restore wird Kernel 4.19 (Debian)** verwendet
 +  * Eintrag für PXE BIOS Boot über TFTP (https://urbackup.atlassian.net/wiki/spaces/US/pages/1441795/Restoring+Images+from+PXE) - dann könnte auch anderer Kernel verwendet werden hinsichtlich **Treiberunterstützung**
 +
 +<code>
 +LABEL UrBackup Restore
 +menu label Urbackup Restore Backup
 +kernel urbackup/live/vmlinuz
 +append initrd=urbackup/live/initrd.img boot=live config username=urbackup toram noswap fetch=tftp://IP_ADRESSE_TFTP_SERVER/urbackup/live/filesystem.squashfs
 +</code>
 +
 +
 +  * **Migration** von Urbackup Server Installation **ohne Backupdaten** jedoch mit Einstellungen von altem System (2016 Standard) auf neues System (2019 Standard)
 +    * Installation gleiche Serverversion wie auf "altem System"
 +    * Deaktivieren und beenden von Urbackup Server Dienst auf altem und neuem System
 +    * Kopieren von C:\Programme..\urbackup Server\*.* von altem System auf neues System (damit auch die Keys für die Authentifizierung bleiben, alle Dateien überschreiben auf neuem System)
 +    * Verzeichnis / Laufwerk für Backup wie auf altem System auf neuem System erstellen
 +    * Urbackup Server Dienst wieder starten -> sobald die Clients im Web Menü sichtbar werden - vollständige Abbildsicherung auslösen / IP vom alten System muss **nicht** übernommen werden
 +===== Altaro =====
 +  * Altaro 8 - **nw.js** Screen / Windows 2019 Standard (https://help.altaro.com/support/solutions/articles/43000467363-getting-nw-js-on-startup-here-s-how-to-fix-it-)
 +    * **Ausloggen** und neu einloggen / beim Check von **%Temp%** existiert das Verzeichnis nicht mehr 
 +
 +  * Bei den Einstellungen VSS Copy beachten bei virtuellen Domain Controllern ! 
 +  * Scheduled Test Restores einrichten und die Daten des Backups regelmäßig überprüfen lassen
 +  * Notifications per E-Mail konfigurieren / für den Fall dass sie nicht funktioniert haben
 +====== HP Aruba ======
 +  * Für Cronjob siehe "HP Pro Curve"
 +  * SSH Server Keys müssen bereits "accepted" worden sein / sonst hängt er bei der Accept Key Frage
 +  * **backup-aruba.expect**
 +<code>
 +#!/usr/bin/expect -f
 +
 +set timeout 60
 +
 +log_user 0
 +
 +spawn ssh USERNAME@[lindex $argv 0]
 +
 +
 +expect "password:"
 +send "PASSWORD\r"
 +
 +#2021-02-08 cc: think wisely if you want to send password as argument to call
 +#send "[lindex $argv 1]\r" 
 +
 +expect "continue"
 +
 +send "\r"
 +
 +expect "#"
 +
 +send "terminal length 1000\r"
 +
 +expect "#"
 +
 +log_user 1
 +
 +send "show config\r"
 +
 +expect "#"
 +
 +
 +send "exit\r"
 +
 +expect ">"
 +
 +send "exit\r"
 +
 +expect "?"
 +
 +send "y\r"
 +
 +expect eof
 +
 +</code>
 +====== HPE Comware  ======
 +  * Für Cronjob siehe "HP Pro Curve"
 +  * SSH Server Keys müssen bereits "accepted" worden sein / sonst hängt er bei der Accept Key Frage
 +  * **backup-hp-comware-switches.expect**
 +
 +<code>
 +#!/usr/bin/expect -f
 +
 +set timeout 60
 +
 +spawn ssh admin@[lindex $argv 0]
 +
 +expect "password:"
 +send "PASSWORD\r"
 +#2021-02-08 cc: think wisely if you want to send password as argument to call
 +#send "[lindex $argv 1]\r" 
 +
 +expect ">"
 +
 +send "xtd-cli-mode\r" 
 +
 +expect "]:"
 +
 +send "Y\r"
 +
 +expect "Password:"
 +
 +send "foes-bent-pile-atom-ship\r" 
 +
 +expect ">"
 +
 +send "screen-length disable\r"
 +
 +expect ">"
 +
 +send "show current-configuration\r"
 +
 +expect ">"
 +
 +send "quit\r"
 +</code>
  
 ====== HP Pro Curve  ====== ====== HP Pro Curve  ======
Zeile 151: Zeile 343:
 set ip_address [lindex $argv 0]; set ip_address [lindex $argv 0];
 set prompt "#" set prompt "#"
-set username "USERNAME_SWITCHES\r" +set username "USERNAME\r" 
-set password "PASSWORD_SWITCHES\r"+set password "PASSWORD\r"
  
     log_user 0      log_user 0 
Zeile 161: Zeile 353:
     send $password     send $password
     expect $prompt     expect $prompt
-    # To avoid sending 'Enter' key on huge configurations +    send "terminal length 1000\r"
-    send "terminal length 0\r"+
     expect $prompt     expect $prompt
-    #set timeout 120;# Increasing timeout to 2mins, as it may take more time to get the prompt+    set timeout 120
     log_user 1     log_user 1
     send "show config\r"     send "show config\r"
     expect $prompt     expect $prompt
-    #set timeout 20; # Reverting to default timeout +    set timeout 20
-    # Sending 'exit' at global level prompt will close the connection+
     send "exit\r"     send "exit\r"
 +    expect ">"
 +    send "exit\r"
 +    expect "?"
 +    send "y\r"
     expect eof     expect eof
 +
  
 </code> </code>
Zeile 269: Zeile 464:
 </code> </code>
  
 +  * **backup-lvm-files.sh**
 +  * Um einen LVM Snapshot read only zu mounten und dann per RSYNC mit einem Verzeichnis zu syncen / kann mit rsnapshot backup_exec kombiniert werden 
 +<code>
 +#!/bin/bash
 +
 +
 +function bailout ()
 +{
 +
 + echo -e "$1"
 +
 + [ -z "$2" ] || lvremove -q -f "$2"
 +
 + exit 2
 +
 +}
 +
 +function usage ()
 +{
 + echo -e "$1"
 + exit 1
 +
 +
 +}
 +
 +RSYNC_DEFAULT_OPTIONS="--dry-run -a --delete  --numeric-ids " 
 +
 +RSYNC_DEFAULT_OPTIONS_ARRAY=($RSYNC_DEFAULT_OPTIONS)
 +
 +ARGUMENTS=$#
 +SIZE_SNAPSHOT="10G"
 +BUFFER="10M"
 +
 +TMP_MOUNT_POINT="/mnt/tmp"
 +
 +which lvcreate > /dev/null || bailout "lvcreate not found"
 +which lvremove > /dev/null || bailout "lvremove not found"
 +which rsync > /dev/null || bailout "rsync not found"
 +which kpartx > /dev/null || bailout "kpartx not found"
 +which mount > /dev/null || bailout "mount not found"
 +which mountpoint > /dev/null || bailout "mountpoint not found"
 +
 +
 +if [ $ARGUMENTS != 2 ] &&  [ $ARGUMENTS != 3 ]
 +then
 +
 + bailout "Usage: $0 PATH_TO_LVM_VOLUME BACKUP_DIRECTORY [ \""RSYNC_OPTIONS\"" ]"
 +
 +fi
 +
 +LVM_PATH="$1"
 +BACKUP_DIRECTORY="$2"
 +RSYNC_CUSTOM_OPTIONS="$3"
 +
 +[ -n "$3" ] && RSYNC_DEFAULT_OPTIONS_ARRAY+=($RSYNC_CUSTOM_OPTIONS)
 +
 +
 +[ ! -r $LVM_PATH ] && bailout "FAIL: Cannot read $LVM_PATH VOLUME"
 +
 +[ ! -d $BACKUP_DIRECTORY ] && bailout "FAIL: $BACKUP_DIRECTORY is already here aborting"
 +
 +[ ! -d $TMP_MOUNT_POINT ] && bailout "FAIL: $TMP_MOUNT_POINT directory not found"
 +
 +mountpoint -q $TMP_MOUNT_POINT && bailout "FAIL: $TMP_MOUNT_POINT is already mounted FAIL"
 +
 +LVM_NAME=$(echo ${LVM_PATH##*/})
 +
 +LVM_NAME_SNAPSHOT="$LVM_NAME""_snapshot"
 +
 +LVM_PATH_SNAPSHOT="${LVM_PATH%%$LVM_NAME}$LVM_NAME_SNAPSHOT"
 +
 +[ -r $LVM_PATH_SNAPSHOT ] && bailout "FAIL: Snapshot: $LVM_PATH_SNAPSHOT already here aborting"
 +
 +lvcreate -L $SIZE_SNAPSHOT -s -n $LVM_NAME_SNAPSHOT $LVM_PATH > /dev/null || bailout "FAIL: Could not create Snapshot: $LVM_NAME_SNAPSHOT"
 +
 +
 +[ $? == "0"  ] || bailout "FAIL: $LVM_PATH_SNAPSHOT could not be created"
 +
 +
 +MOUNT_PATH="$LVM_PATH_SNAPSHOT"
 +
 +DEVICE_MAPPER_ENTRY=$(kpartx -av $LVM_PATH_SNAPSHOT)
 +
 +RETURN_SUCCESS=$?
 +
 +[ $? != "0" ] && bailout "FAIL: Kpartx did not return 0 - error" "$LVM_PATH_SNAPSHOT"
 +
 +DEVICE_MAPPER_ENTRY=$(echo $DEVICE_MAPPER_ENTRY | cut -f 3 -d" ")
 +
 +[ -z $DEVICE_MAPPER_ENTRY ] || MOUNT_PATH="/dev/mapper/""$DEVICE_MAPPER_ENTRY"
 +
 +
 +mount -o ro "$MOUNT_PATH" "$TMP_MOUNT_POINT" || bailout "FAIL: could not mount $MOUNT_PATH to $TMP_MOUNT_POINT" "$LVM_PATH_SNAPSHOT"
 +
 +
 +rsync "${RSYNC_DEFAULT_OPTIONS_ARRAY[@]}" "$TMP_MOUNT_POINT/" "$BACKUP_DIRECTORY/"
 +
 +RETURN_RSYNC=$?
 +
 +umount $TMP_MOUNT_POINT
 +
 +kpartx -dv $LVM_PATH_SNAPSHOT > /dev/null
 +
 +lvremove -q -f $LVM_PATH_SNAPSHOT > /dev/null
 +
 +exit $RETURN_RSYNC
 +</code>
  
   * **integ.sh**   * **integ.sh**
Zeile 361: Zeile 663:
   * rsnapshot mit **btrfs**    * rsnapshot mit **btrfs** 
  
 +<code>
 +rsnapshot.conf
 +...
 +cmd_cp          /usr/local/sbin/rsnapshot_btrfs_cp.sh
  
 +# uncomment this to use the rm program instead of the built-in perl routine.
 +#
 +cmd_rm          /usr/local/sbin/rsnapshot_btrfs_rm.sh
  
 +...
 +</code>
 +  * **rsnapshot_btrfs_cp.sh**
  
 +<code>
 +#!/bin/bash
  
-  * rsnapshot mit **borg**+# Arg 1: -al 
 +# Arg 2: /path/daily.0 
 +# Arg 3: /path/daily.1
  
-===== borg  =====+btrfs subvolume snapshot -r $2 $3 >/dev/null 
 +</code> 
 + 
 +  * **rsnapshot_btrfs_rm.sh** 
 + 
 +<code> 
 +#!/bin/bash 
 + 
 +# Arg 1: -rf 
 +# Arg 2: /path/daily.5/ 
 + 
 +# echo 1: $1  2: $@ 
 + 
 +# Try to delete the given path with btrfs subvolume delete first 
 +# if this fails fall back to normal rm 
 +if [  "$1" = "-rf"  -a  "$3" = ""  ]; then 
 +    # "trying to delete with btrfs" 
 +    btrfs subvolume show "$2" &>/dev/null && btrfs subvolume delete "$2" &>/dev/null && exit 0 
 +     
 +    [[ -d "$2" ]] &&  rm -rf "$2" && exit 0 
 +             
 +    exit 2 
 +fi 
 + 
 +exit 2 
 +</code> 
 + 
 +  * rsnapshot mit **borg** **cron job** 
 +  * In der Konfiguration der rsnapshot Backups existiert nur mehr daily.0 d.h. **retain daily 1** und beide Backup Jobs (customers und pannoniait) müssen bereits **abgeschlossen** sein  
 + 
 +<code> 
 +30   06 * * 1-5 root   ( [[ ! -f /var/run/rsnapshot-customers.pid ]] && [[ ! -f /var/run/rsnapshot-pannoniait.pid ]] && borg create -x --numeric-owner --compression lz4 /mnt/storage/backups/borg/::d.$(date +"\%F") /mnt/storage/backups/customers/daily.0/ /mnt/storage/backups/pannoniait/daily.0/ && borg prune -P d -d 5 /mnt/storage/backups/borg ) || echo "Could not perform daily borg backup" 
 + 
 +30   06 * * 6 root  ( [[ ! -f /var/run/rsnapshot-customers.pid ]] && [[ ! -f /var/run/rsnapshot-pannoniait.pid ]] && borg create -x --numeric-owner --compression lz4 /mnt/storage/backups/borg/::w.$(date +"\%F") /mnt/storage/backups/customers/daily.0/ /mnt/storage/backups/pannoniait/daily.0/ && borg prune -P w -w 4 /mnt/storage/backups/borg ) || echo "Could not perform weekly borg backup" 
 + 
 +30   07 1 * * root ( [[ ! -f /var/run/rsnapshot-customers.pid ]] && [[ ! -f /var/run/rsnapshot-pannoniait.pid ]] && borg create -x --numeric-owner --compression lz4 /mnt/storage/backups/borg/::m.$(date +"\%F") /mnt/storage/backups/customers/daily.0/ /mnt/storage/backups/pannoniait/daily.0/ && borg prune -P m -m 2 /mnt/stroage/backups/borg ) || echo "Could not perform monthly borg backup 
 +</code> 
 + 
 +===== borg - generell  =====
   * Backup Tests mit borg - Achtung **unverschlüsselt** da Testgerät ohnehin **vollverschlüsselt** ist   * Backup Tests mit borg - Achtung **unverschlüsselt** da Testgerät ohnehin **vollverschlüsselt** ist
 +  * Ganze LVM Devices basierend auf Snapshot backupppen - sollte konsistent sein **backup-lvm-drive-borg.sh**
 +<code>
 +#!/bin/bash
 +
 +function bailout ()
 +{
 +
 + echo -e "$1" 1>&2
 + exit 2
 +
 +}
 +
 +function usage ()
 +{
 + echo -e "$1"
 + exit 1
 +
 +
 +}
 +
 +# LVM PATH / generate LVM snapshot name suffix snapshot / compress devices / output PATH
 +
 +ARGUMENTS=$#
 +SIZE_SNAPSHOT="50G"
 +BORG_NR_TO_KEEP="4"
 +
 +which lvcreate > /dev/null || bailout "lvcreate not found"
 +which borg > /dev/null || bailout "borg cannot be found"
 +which lvremove > /dev/null || bailout "lvremove not found"
 +
 +[ $ARGUMENTS -lt 2 ] && bailout "Usage: $0 PATH_TO_BORG_REPOSITORY PATH_TO_LVM_VOLUME1 PATH_TO_LVM_VOLUME2 "
 +
 +BACKUP_REPOSITORY=$(echo $1 | cut -d: -f 1)
 +
 +[ -r $BACKUP_REPOSITORY ] || bailout "FAIL: $BACKUP_REPOSITORY cannot be read"
 +
 +[ -w $BACKUP_REPOSITORY ] || bailout "FAIL: $BACKUP_REPOSITORY cannot be written to"
 +
 +for i in "${@:2}" ; do
 +
 + LVM_PATH="$i"
 + LVM_PATH_SNAPSHOT="$LVM_PATH""_snapshot"
 +      
 +      [ ! -r $LVM_PATH ] && bailout "FAIL: Cannot read \"$LVM_PATH\" VOLUME"
 +      [ -r  $LVM_PATH_SNAPSHOT ] && bailout "FAIL: Attention snapshot still there: $LVM_PATH_SNAPSHOT"     
 +done
 +
 +lvm_snapshots=""
 +
 +for i in "${@:2}" ; do
 +
 +        LVM_PATH="$i"
 +        LVM_PATH_SNAPSHOT="$LVM_PATH""_snapshot"
 +        
 + lvcreate -L $SIZE_SNAPSHOT -s -n $LVM_PATH_SNAPSHOT $LVM_PATH > /dev/null || bailout "FAIL: Could not create Snapshot: $LVM_NAME_SNAPSHOT"
 +        lvm_snapshots="$lvm_snapshots $LVM_PATH_SNAPSHOT"
 +done
 +
 +borg create --stats --compression=lz4 --read-special "$1" $lvm_snapshots
 +
 +RET_CODE_BORG="$?"
 +
 +for i in "${@:2}" ; do
 +
 +        LVM_PATH="$i"
 +        LVM_PATH_SNAPSHOT="$LVM_PATH""_snapshot"
 +
 + lvremove -q -f $LVM_PATH_SNAPSHOT >/dev/null
 +done
 +
 +borg prune --keep-last $BORG_NR_TO_KEEP $BACKUP_REPOSITORY
 +
 +exit $RET_CODE_BORG
 +
 +</code>
 +
   * Durchgeführt auf Kali Linux - Debian Testing   * Durchgeführt auf Kali Linux - Debian Testing
 <code> <code>
Zeile 417: Zeile 847:
  
 root@mrChief:/mnt# borg prune --keep-last 4 /mnt/backup/mrChief/ root@mrChief:/mnt# borg prune --keep-last 4 /mnt/backup/mrChief/
 +</code>
 +
 +===== borg - hetzner storage  =====
 +<code>
 +1. key verteilen
 +
 +https://wiki.hetzner.de/index.php/Backup_Space_SSH_Keys
 +
 +root@mrStorage:~# echo -e "mkdir .ssh \n chmod 700 .ssh \n put /root/.ssh/id_rsa.pub .ssh/authorized_keys \n chmod 600 .ssh/authorized_keys" | sftp u12345678@u12345678.your-storagebox.de
 +The authenticity of host 'u12345678.your-storagebox.de (176.9.161.59)' can't be established.
 +RSA key fingerprint is SHA256:EMlfI8GsRIfpVkoW1H2u0zYVpFGKkIMKHFZIRkf2ioI.
 +Are you sure you want to continue connecting (yes/no)? yes
 +Warning: Permanently added 'u12345678.your-storagebox.de,176.9.161.59' (RSA) to the list of known hosts.
 +u12345678@u12345678.your-storagebox.de's password: 
 +Connected to u12345678@u12345678.your-storagebox.de.
 +sftp> mkdir .ssh 
 +sftp>  chmod 700 .ssh 
 +Changing mode on /.ssh
 +sftp>  put /root/.ssh/id_rsa.pub .ssh/authorized_keys 
 +Uploading /root/.ssh/id_rsa.pub to /.ssh/authorized_keys
 +/root/.ssh/id_rsa.pub                         100%  740    27.0KB/  00:00    
 +sftp>  chmod 600 .ssh/authorized_keys
 +Changing mode on /.ssh/authorized_keys
 +
 +
 +
 +2. Repo initialisieren
 +
 +borg init --encryption=keyfile  ssh://u12345678@u12345678.your-storagebox.de:23/./borg/
 +
 +Keymaterial befindet sich ausschließlich auf "mrStorage" dem Server der das Backup in die Hetzner CLoud durchführt
 +
 +3. Backup Keys exportieren - es wird Keyfile und Passphrase benötigt - backup des keyfiles
 +
 +borg key export  ssh://u12345678@u12345678.your-storagebox.de:23/./borg/ /tmp/borg_keyfile
 +
 +3. Common Commands
 +
 +root@mrStorage:~# borg create --compression lz4  --list --dry-run  ssh://u12345678@u12345678.your-storagebox.de:23/./borg/::{now} /root/fw.log.2.gz 
 +- /root/fw.log.2.gz
 +
 +root@mrStorage:~# borg create --compression lz4  --list  ssh://u12345678@u12345678.your-storagebox.de:23/./borg/::{now} /root/fw.log.2.gz 
 +Enter passphrase for key /root/.config/borg/keys/u12345678_your_storagebox_de__borg: 
 +A /root/fw.log.2.gz
 +
 +root@mrStorage:~# borg create --compression lz4  --list --dry-run  ssh://u12345678@u12345678.your-storagebox.de:23/./borg/::{now} /root/fw.log.2.gz 
 +- /root/fw.log.2.gz
 +
 +root@mrStorage:~# borg info   ssh://u12345678@u12345678.your-storagebox.de:23/./borg/
 +Enter passphrase for key /root/.config/borg/keys/u12345678_your_storagebox_de__borg: 
 +Location: ssh://u12345678@u12345678.your-storagebox.de:23/./borg
 +Encrypted: Yes (key file)
 +Key file: /root/.config/borg/keys/u12345678_your_storagebox_de__borg
 +------------------------------------------------------------------------------
 +                       Original size      Compressed size    Deduplicated size
 +All archives:                4.48 MB              4.50 MB              4.50 MB
 +
 +                       Unique chunks         Total chunks
 +Chunk index:                                          5
 +
 +root@mrStorage:~# borg list   ssh://u12345678@u12345678.your-storagebox.de:23/./borg/
 +Enter passphrase for key /root/.config/borg/keys/u12345678_your_storagebox_de__borg: 
 +2020-03-05T23:35:02                  Thu, 2020-03-05 23:35:11 [0fe96fe6a40b0eb5db5955affad70a570e3a37cb3d3dd9f6e9a3ba0a538eafc2]
 +
 +root@mrStorage:~# borg mount  ssh://u12345678@u12345678.your-storagebox.de:23/./borg/ /mnt/tmp
 +Enter passphrase for key /root/.config/borg/keys/u12345678_your_storagebox_de__borg: 
 +
 +</code>
 +  * **/usr/local/bin/hetzner_borg_backup.sh**
 +
 +<code>
 +
 +#!/bin/bash
 +
 +export BORG_PASSPHRASE="PASSPHRASE"
 +REPOSITORY="ssh://u12345678@u12345678.your-storagebox.de:23/./borg/"
 +
 +DIRECTORIES="/mnt/storage/"
 +
 +HOST=$(hostname --fqdn)
 +
 +START_TIME=$(date +%Y.%m.%d-%H.%M.%S)
 +
 +date1=$(date -u +"%s")
 +
 +echo -e  "Program: $0 \nstarted at: $START_TIME\nBacking Up: $DIRECTORIES\nHost: $HOST"
 +
 +#2020-04-08 cc: Achtung sonst konsumiert er den gesamten Upload und die Leitung steht daher: Rate limit ~6 Mbit upload / bei 10Mbit verfügbarem Upload
 +
 +borg create --compression lz4  --stats --remote-ratelimit 700 --exclude '*/.snapshots/*' $REPOSITORY::{now} $DIRECTORIES
 +
 +
 +[[ $? == "0" ]] && borg prune --stats --keep-last 6 $REPOSITORY
 +
 +END_TIME=$(date +%Y.%m.%d-%H.%M.%S)
 +
 +date2=$(date -u +"%s")
 +diff=$(($date2-$date1))
 +
 +echo "$(($diff / 60)) minutes and $(($diff % 60)) seconds elapsed."
 +echo "$(($diff / 86400 )) days elapsed. "
 +
 +echo -e "Program ended successfully : $0 \nended at: $END_TIME\n"
 </code> </code>
 ===== triggered ===== ===== triggered =====
Zeile 619: Zeile 1152:
 ===== etc ===== ===== etc =====
   * rsync für blockdevices Kopieren "--copy-devices"   * rsync für blockdevices Kopieren "--copy-devices"
 +  * **Update**
 +<code>
 +rsync (3.2.0-1) unstable; urgency=low
 +
 +  This latest release changed two parameters which used to be present on the
 +  Debian packaging of rsync as upstream now integrated the patches.
 +
 +  Previous parameter:
 +  --copy-devices: write to devices as files (implies --inplace)
 +  Is now called: --write-devices
 +</code>
 +
 +
  
 <code> <code>
Zeile 644: Zeile 1190:
 sent 1,009,903 bytes  received 505,075 bytes  5,439.78 bytes/sec sent 1,009,903 bytes  received 505,075 bytes  5,439.78 bytes/sec
 </code> </code>
 +
 +
 +  * rsync - Ausgabe ob etwas geändert werden würde - dry run und count
 +  * **rsync -iaun --delete foo1/ foo2/ | wc -l**
 +<code>
 +0
 +</code>
 +
know-how/backup.1571729700.txt.gz · Zuletzt geändert: 2019/10/22 09:35 von cc