linuxkurs/beispiele/17/wp-backup/wp-backup.sh

34 lines
695 B
Bash
Raw Permalink Normal View History

2019-03-11 11:31:18 +01:00
#!/bin/bash
BACKUPFILE=$1
BACKUPZIEL=$2
NOW="$(date +"%d-%m-%Y")"
function db_backup {
# Vars
host=localhost
user=XXXXXXX
pass=XXXXXXX
db=wordpress
2019-03-13 20:31:03 +01:00
mysqldump --opt --add-drop-table -h$host -u$user -p$pass $db > wp-db.sql
2019-03-11 11:31:18 +01:00
}
function file_backup {
cd /home/dany/local-dev/wp
tar -cJf ~/tmp/$BACKUPFILE-$NOW.tar.xz wp-content/themes wp-content/uploads #./wp-db-$NOW.sql
}
function upload {
2019-03-11 17:07:54 +01:00
/usr/bin/rsync -aze 'ssh -i /path/to/ssh-keyfile' \
/home/dany/tmp/$BACKUPFILE-$NOW.tar.xz server-name-hier:target-dir/ >> backup.log 2>&1
#oder
#scp /home/dany/tmp/$BACKUPFILE-$NOW.tar.xz server-name-hier:target-dir/ >> backup.log 2>&1
2019-03-11 11:31:18 +01:00
}
# Funktionsaufrufe
db_backup
file_backup
2019-03-13 20:31:03 +01:00
upload