====== Automatisches Backup ====== \\ ===== Installation ===== sudo apt-get install duplicity \\ ===== Crontab ===== 0 3 * * * root /opt/backups/backup_duplicity.sh >>/var/log/duplicity.log 2>&1 \\ ===== Backup auf der Hetzner Storagebox ===== Das ganze läuft auf dem Hetzner Server und verbindet sich via SFTP.\\ In /root/.ssh/config:\\ # backup server Host storagebox HostName u157627.your-storagebox.de User u157627 Port 23 IdentityFile /root/.ssh/storage_box \\ Der SSH-Key liegt also in /root/.ssh/ und heißt "storage_box".\\ \\ Skript in /opt/backups/:\\ #!/bin/bash #BACKUPDIR="/home/backups" # standard Pfad can be overwritten STORAGEBOX="u157627@storagebox:/144/backups" #export PASSPHRASE="fix404" # Password for encryption SCRIPT_DIR="$(dirname "$0")" SOURCE="$SCRIPT_DIR/backup_files.txt" EXCLUDE="$SCRIPT_DIR/backup_exclude.txt" VOLSIZE_IN_MB=200 #DATUM="$(date +%Y%m%d)" # Date for the monthly backup #ZEIT="$(date +%H%M)" # time # Check free space on storage box? #freespace=$(df -k $BACKUPDIR |tail -1 |awk '{print $4}') #if [ $freespace -lt 50000000 ]; then # echo not enough space on backup device # exit #fi # Sichern duplicity --no-encryption --volsize $VOLSIZE_IN_MB --full-if-older-than 6D --exclude-filelist=$EXCLUDE --include-filelist=$SOURCE --exclude='**' / pexpect+sftp://$STORAGEBOX now=`date` echo "Finished backup at $now" # Verifizieren duplicity verify --no-encryption --exclude-filelist=$EXCLUDE --include-filelist=$SOURCE --exclude='**' pexpect+sftp://$STORAGEBOX / now=`date` echo "Finished verify at $now" # Löschen duplicity remove-older-than 1M --force --no-encryption pexpect+sftp://$STORAGEBOX now=`date` echo "Finished removing at $now" \\ backup_files.txt:\\ /etc/** /opt/** /home/** \\ backup_exclude.txt:\\ /home/backups/ /home/old_server_backups/ \\ ===== Status des Backups überprüfen ===== Skript backup_status.sh:\\ #!/bin/bash STORAGEBOX="u157627@storagebox:/144/backups" # Status duplicity collection-status pexpect+sftp://$STORAGEBOX