linuxkurs/beispiele/5/09-backup.sh
2019-01-10 12:09:22 +01:00

38 lines
788 B
Bash
Executable File

#!/bin/bash
# Get date in dd-mm-yyyy format
NOW="$(date +"%d-%m-%Y")"
function file_backup {
wpbackupfile="wordpress-backup-$NOW.tar.gz"
oxidbackupfile="oxid-back-$NOW.tar.gz"
echo 'WP Files Backup --- building tar File...'
tar -czf $wpbackupfile /var/html/www/rvv/wp*
echo '+DONE'
echo 'oxid Files Backup --- building tar File...'
tar -czf $oxidbackupfile /var/html/www/rvv/shop
echo '+DONE'
}
function oxid_db_backup {
host=localhost
user=rvv
pass=xxxxxxxxx
db=webshop
echo 'oxid DB Export ------> '
mysqldump --opt --add-drop-table -h$host -u$user -p$pass $db | gzip > oxid-db-$NOW.sql.gz
}
backupdir=~/backup
cd ~ ; mkdir $backupdir ; cd $backupdir
oxid_db_backup
file_backup
# delete old backups
find $backupdir -mtime +10 -type f -delete