2014-02-25 19:11:29 +00:00
|
|
|
#!/bin/bash
|
2014-04-15 19:23:55 +00:00
|
|
|
# 2014 by Mainboarder.de
|
2014-02-25 19:11:29 +00:00
|
|
|
#
|
|
|
|
# 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/"
|
2014-04-15 19:23:55 +00:00
|
|
|
sshkey="/etc/ssh/ssh_host_dsa_key"
|
2014-02-25 19:11:29 +00:00
|
|
|
encryption="path/to/enc.key"
|
|
|
|
external="user@extern.server.de"
|
2014-04-15 19:23:55 +00:00
|
|
|
externalpath="/media/mountpoint/backups"
|
2014-02-25 19:11:29 +00:00
|
|
|
|
|
|
|
# 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
|
2014-04-15 19:23:55 +00:00
|
|
|
scp -i $sshkey ./backup-html-$datum.enc.tar.gz $external:$externalpath
|
2014-02-25 19:11:29 +00:00
|
|
|
|
|
|
|
rm backup-html-$datum.enc.tar.gz
|
|
|
|
|
|
|
|
rm -r $temp
|
|
|
|
mkdir $temp
|