65 lines
1.1 KiB
Bash
65 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
NOW="$(date +"%d-%m-%Y")"
|
|
|
|
# websites folder
|
|
WEBSITESDIR="."
|
|
|
|
# local backup folder
|
|
BACKUPDIR="./backups"
|
|
|
|
# Erstelle backupdir falls nicht vorhanden
|
|
if [ ! -d $BACKUPDIR ]; then
|
|
mkdir $BACKUPDIR
|
|
fi
|
|
|
|
# Unterverzeichnisse von html die gebackuppt werden sollen
|
|
# Array
|
|
declare -a liste
|
|
|
|
liste=(
|
|
"omikron"
|
|
"amazon.de"
|
|
"spiegel.de"
|
|
"google.de"
|
|
"omikron/china"
|
|
"omikron/swiss"
|
|
)
|
|
|
|
function create_websites_backup {
|
|
|
|
cd $WEBSITESDIR
|
|
|
|
# Unter Verwendung des Array $liste
|
|
for i in "${liste[@]}"; do
|
|
if [ -d $i ]; then
|
|
tag=$(echo $i | sed 's/\//-/')
|
|
tar -zcf $BACKUPDIR/$tag-$NOW.tar.gz $WEBSITESDIR/$i
|
|
else
|
|
echo "File or Directory $i not found!\n"
|
|
fi
|
|
done
|
|
|
|
# oder unter Verwendung einer Datei mit der Verz. Liste
|
|
# while read i; do
|
|
# tar -zcf $BACKUPDIR/$tag-$NOW.tar.gz $WEBSITESDIR/$i
|
|
# done < 'backup-list.txt'
|
|
|
|
}
|
|
|
|
# mysql backup
|
|
function do_sql_backup {
|
|
cd $BACKUPDIR
|
|
tag=db-$4-$NOW
|
|
|
|
mysqldump --opt --add-drop-table -h$1 -u$2 -p$3 $4 | gzip > $tag.sql.gz
|
|
}
|
|
|
|
#do_sql_backup "localhost" "db_user" "secret_pw" "db_name"
|
|
|
|
create_websites_backup
|
|
|
|
cd -
|
|
|
|
|