Ripristinare il backup di rsnapshot

Support Wissensdatenbank

Du bist hier:
Print

Ripristinare il backup di rsnapshot

Se un backup rsync o rsnapshot deve essere ripristinato, deve essere fatto molto rapidamente. A questo scopo, abbiamo creato degli script allegati per ripristinare i dati il più rapidamente possibile. Entrambi gli script possono essere eseguiti in parallelo per ripristinare i dati web e email allo stesso tempo. Lo script avvia diversi processi paralleli per accelerare il ripristino. Il prerequisito per questo è che il server di backup possa accedere al server di destinazione tramite una chiave SSH.

Requisiti:
– backup rsnapshot
– Chiave SSH memorizzata sul server di destinazione
– Server Plesk

Lo script avvia x processi Rsync specificati. Lo script può essere adattato a qualsiasi percorso. Ad esempio, “realpath” può essere cambiato in “/var/lib/mysql” per ripristinare ogni database dal file di backup individualmente. La chiave di backup SSH può anche essere scambiata con sshkey.

 

 

Ripristinare i file web (webrestore.sh):

#!/bin/bash

#Settings
process_limit=120						# Max amount of rsync processes
server="sr00"							# Server according to Backup path /volume1/backup/{$server}
daily="0"							# Daily number according to backup path starting with 0 like daily.0 /volume1/backup/$server/daily.{$daily}
remote="sr00.firestorm.ch"					# URL or IP of Target Server.
sshkey="/root/.ssh/backupkey"					# Rsync SSH Key
backuppath="/volume1/backup/$server/daily.$daily/$server"	# Source backup path from rsnapshot	(No tailing slashes)
realpath="/var/www/vhosts"					# Server Source location	        (No tailing slashes)

#Processes Array
processes=()

function check_processes {
  #For Each Rsync Process
  for pid in "${processes[@]}"; do
    #If Process has died / ended
    if ! ps -p $pid > /dev/null ; then
      #For Each Numbered Process Array
      for i in "${!processes[@]}"; do
        #If numberes Process equals died process
        if [[ ${processes[i]} = $pid ]]; then
          #Remove Process from array
          unset 'processes[i]'
        fi
      done
    fi
  done
}

#For Each Website in Backup
for folder in $backuppath$realpath/* ; do
  domain="$(basename $folder)"
  /bin/echo "##############################"

  #wait if more than 30 processes
  while [ ${#processes[@]} -gt $process_limit ]
  do
    check_processes
    /bin/sleep 5s
  done
    
  /bin/echo "/bin/rsync --stats --progress -avz --delete $folder/ root@$server.firestorm.ch:$realpath/$domain/ (${#processes[@]} / $process_limit)"
  /bin/rsync --stats --progress -avz --delete -e "ssh -p 22 -i $sshkey" $folder/ root@$remote:$realpath/$domain/ &
  processes+=($!)
done

 

Ripristinare i dati delle e-mail (webrestore.sh):

#!/bin/bash

#Settings
process_limit=120						# Max amount of rsync processes
server="sr00"							# Server according to Backup path /volume1/backup/{$server}
daily="0"							# Daily number according to backup path starting with 0 like daily.0 /volume1/backup/$server/daily.{$daily}

remote="sr00.firestorm.ch"                                      # URL or IP of Target Server.
sshkey="/root/.ssh/backupkey"		  	                # Rsync SSH Key
backuppath="/volume1/backup/$server/daily.$daily/$server"	# Source backup path		(No tailing slashes)
realpath="/var/qmail/mailnames"					# Server Source location	(No tailing slashes)

#Processes Array
processes=()

function check_processes {
  #For Each Rsync Process
  for pid in "${processes[@]}"; do
    #If Process has died / ended
    if ! ps -p $pid > /dev/null ; then
      #For Each Numbered Process Array
      for i in "${!processes[@]}"; do
        #If numberes Process equals died process
        if [[ ${processes[i]} = $pid ]]; then
          #Remove Process from array
          unset 'processes[i]'
        fi
      done
    fi
  done
}

#For Each Mailname in Backup
for folder in $backuppath$realpath/* ; do
  domain="$(basename $folder)"
  /bin/echo "##############################"

  #wait if more than 30 processes
  while [ ${#processes[@]} -gt $process_limit ]
  do
    check_processes
    /bin/sleep 5s
  done
    
  /bin/echo "/bin/rsync --stats --progress -avz --delete $folder/ root@$server.firestorm.ch:$realpath/$domain/ (${#processes[@]} / $process_limit)"
  /bin/rsync --stats --progress -avz --delete -e "ssh -p 22 -i $sshkey" $folder/ root@$remote:$realpath/$domain/ &
  processes+=($!)
done

 

wiederherstellen:

 

War dieser Artikel hilfreich?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
Wie können wir diesen Artikel verbessern?
Please submit the reason for your vote so that we can improve the article.
Brauchst du Hilfe?
Related Post