initial commit

This commit is contained in:
Robin Kloppe 2014-02-25 20:11:29 +01:00
commit 3d2829511b
2 changed files with 88 additions and 0 deletions

44
backup-server.sh Normal file
View file

@ -0,0 +1,44 @@
#!/bin/bash
# 2013 by Mainboarder.de
#
# 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.
#
path="var/customers/backups/"
temp="var/customers/temp-backup-path/"
encryption="path/to/enc.key"
external="user@extern.server.de"
# um <<tar - Entferne führende „/“ von Elementnamen>> zu vermeiden
cd /
# Ordner finden
for f in $( ls $path); do
# HTML-Dateien finden
for g in $( ls $path$f | grep html); do
# Dateien kopieren
cp $path$f/$g $temp
done
done
#Datum erstellen
datum=$(date +"%d"."%m"."%y")
#Dateien zusammenpacken und komprimieren
tar cfvz backup-html-$datum.tar.gz $temp
#Verschlüsseln und gepackte Datei löschen
openssl aes-256-cbc -kfile $encryption -in backup-html-$datum.tar.gz -out ./backup-html-$datum.enc.tar.gz
rm backup-html-$datum.tar.gz
#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
rm backup-html-$datum.enc.tar.gz
rm -r $temp
mkdir $temp

44
backup-sql.sh Normal file
View file

@ -0,0 +1,44 @@
#!/bin/bash
# 2013 by Mainboarder.de
#
# 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.
#
path="var/customers/backups/"
temp="var/customers/temp-backup-path/"
encryption="path/to/enc.key"
external="user@extern.server.de"
# um <<tar - Entferne führende „/“ von Elementnamen>> zu vermeiden
cd /
# Ordner finden
for f in $( ls $path); do
# SQL-Dateien finden
for g in $( ls $path$f | grep sql); do
# Dateien kopieren
cp $path$f/$g $temp
done
done
#Datum erstellen
datum=$(date +"%d"."%m"."%y")
#Dateien zusammenpacken und komprimieren
tar cfvz backup-sql-$datum.tar.gz $temp
#Verschlüsseln und gepackte Datei löschen
openssl aes-256-cbc -kfile $encryption -in backup-sql-$datum.tar.gz -out ./backup-sql-$datum.enc.tar.gz
rm backup-sql-$datum.tar.gz
#Kopieren und verschlüsselte Datei löschen
scp -i /etc/ssh/ssh_host_dsa_key ./backup-sql-$datum.enc.tar.gz $external:/mnt/usb/backups
rm backup-sql-$datum.enc.tar.gz
rm -r $temp
mkdir $temp