11
This commit is contained in:
parent
5b2f4c9e3a
commit
35d3cd5b96
57
beispiele/11/file-backup.sh
Normal file
57
beispiele/11/file-backup.sh
Normal 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 -
|
||||
|
||||
|
25
beispiele/11/helper/make-dirs.sh
Normal file
25
beispiele/11/helper/make-dirs.sh
Normal 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
|
16
beispiele/11/rsync-backup.sh
Normal file
16
beispiele/11/rsync-backup.sh
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user