decrypt script

more variables
This commit is contained in:
Robin Kloppe 2014-04-15 21:23:55 +02:00
parent d984355a57
commit e91d147cad
4 changed files with 21 additions and 8 deletions

View file

@ -6,4 +6,7 @@ Backup your Froxlor Webhosting to another server. Encrypted, via ssh.
Works until version 0.9.32. Works until version 0.9.32.
SQL works now also for Versions > 0.9.32. SQL works now also for Versions > 0.9.32.
HTML is planned to be backed up with duplicity HTML is planned to be backed up with duplicity
The decrypt.sh file has just two lines. With them you can decrypt and untar your backups as long as they are back on the local storage.
For $encrypt in this file use the same path as you do in any other file

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# 2013 by Mainboarder.de # 2014 by Mainboarder.de
# #
# Keep this comment untouched and do not use this software for military purposes. # Keep this comment untouched and do not use this software for military purposes.
# you are allowed to use this just like you want on your own risk. # you are allowed to use this just like you want on your own risk.
@ -7,8 +7,10 @@
path="var/customers/backups/" path="var/customers/backups/"
temp="var/customers/temp-backup-path/" temp="var/customers/temp-backup-path/"
sshkey="/etc/ssh/ssh_host_dsa_key"
encryption="path/to/enc.key" encryption="path/to/enc.key"
external="user@extern.server.de" external="user@extern.server.de"
externalpath="/media/mountpoint/backups"
# um <<tar - Entferne führende „/“ von Elementnamen>> zu vermeiden # um <<tar - Entferne führende „/“ von Elementnamen>> zu vermeiden
cd / cd /
@ -36,7 +38,7 @@ openssl aes-256-cbc -kfile $encryption -in backup-html-$datum.tar.gz -out ./back
rm backup-html-$datum.tar.gz rm backup-html-$datum.tar.gz
#Kopieren und verschlüsselte Datei löschen #Kopieren und verschlüsselte Datei löschen
scp -i /etc/ssh/ssh_host_dsa_key ./backup-html-$datum.enc.tar.gz $external:/mnt/usb/backups scp -i $sshkey ./backup-html-$datum.enc.tar.gz $external:$externalpath
rm backup-html-$datum.enc.tar.gz rm backup-html-$datum.enc.tar.gz

View file

@ -10,9 +10,10 @@
temp="var/customers/temp-backup-path" temp="var/customers/temp-backup-path"
backuppath="/mnt/usb/backups" backuppath="/mnt/usb/backups"
encryption="/path/to/enc.key" encryption="/path/to/enc.key"
sshkey="/etc/ssh/ssh_host_dsa_key"
external="user@extern.server.de" external="user@extern.server.de"
MYSQL_USER="root" mysql_user="root"
MYSQL_PASSWORD="root" mysql_password="root"
# Programm # Programm
@ -23,11 +24,11 @@ cd /
datum=$(date +"%d"."%m"."%y") datum=$(date +"%d"."%m"."%y")
#Datenbanken finden #Datenbanken finden
databases=`mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema|mysql)"` databases=`mysql -u $mysql_user -p$mysql_password -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema|mysql)"`
#Datenbanken exportieren #Datenbanken exportieren
for db in $databases; do for db in $databases; do
mysqldump -u $MYSQL_USER -p$MYSQL_PASSWORD $db > "$temp/$db.sql" mysqldump -u $mysql_user -p$mysql_password $db > "$temp/$db.sql"
done done
# Alle SQL-Dumps in ein Archiv packen # Alle SQL-Dumps in ein Archiv packen
@ -39,7 +40,7 @@ openssl aes-256-cbc -kfile $encryption -in $temp/../backup-sql-$datum.tar.gz -ou
rm $temp/../backup-sql-$datum.tar.gz rm $temp/../backup-sql-$datum.tar.gz
#Kopieren und verschlüsselte Datei löschen #Kopieren und verschlüsselte Datei löschen
scp -i /etc/ssh/ssh_host_dsa_key $temp/backup-sql-$datum.enc.tar.gz $external:$backuppath scp -i $sshkey $temp/backup-sql-$datum.enc.tar.gz $external:$backuppath
rm -r $temp rm -r $temp
mkdir $temp mkdir $temp

7
decrypt.sh Normal file
View file

@ -0,0 +1,7 @@
##
# This just shows how to decrypt and untar files
# replace $encryption with your path to the encryption file
##
openssl aes-256-cbc -d -kfile $encryption -in file.enc.tar.gz > file.tar.gz
tar xzfv file.tar.gz