This commit is contained in:
Daniel Schubert 2019-02-01 08:51:57 +01:00
parent 5b2f4c9e3a
commit 35d3cd5b96
3 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,57 @@
#!/bin/bash
NOW="$(date +"%d-%m-%Y")"
# websites folder
WEBSITESDIR="."
# local backup folder
BACKUPDIR="./backups"
if [ ! -d $BACKUPDIR ]; then
mkdir $BACKUPDIR
fi
# Array
declare -a liste
# Unterverzeichnisse von html die gebackuppt werden sollen
liste=(
"omikron"
"amazon.de"
"spiegel.de"
"google.de"
"omikron/china"
"omikron/swiss"
)
# websites
function create_websites_backup {
cd $WEBSITESDIR
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
}
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 -

View File

@ -0,0 +1,25 @@
#script zur erstellung einer Test Umgebung
declare -a liste
# Unterverzeichnisse von html die gebackuppt werden sollen
liste=(
"omikron"
"amazon.de"
"spiegel.de"
"google.de"
"omikron/china"
"omikron/swiss"
)
# Meat
for i in "${liste[@]}"; do
mkdir -p $i
echo "<h1>hallo test</h1> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<p> " > $i/index.html
done

View File

@ -0,0 +1,16 @@
#!/bin/bash
USERNAME=XXX
REMOTE_HOST=XXX
# rsync options
# -a = Archive Mode
# -v = Verbode - für das log file
# -z = Compress
# -e = specify the remote shell to use
/usr/bin/rsync -avze 'ssh -i /home/$USERNAME/.ssh/rsync-key' $REMOTE_HOST:/home/$USERNAME/backups/* /local/backup/dir/ >> backup.log 2>&1
# delete backups older than 10 days
#find /local/backup/dir -mtime +10 -type f -delete