Dear visitor, welcome to sourceserver.info. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
Rating: ![]()
by DeaD_EyE, Monday, March 21st 2011, 11:05pm
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
#!/bin/bash
#General
ftp=/home/xxx/backup/ftp
sql=/home/xxx/backup/sql
#Date-String
date=`date +"%Y-%m-%d_%H-%M"`
#MYSQL
dbsuffix="_xxx.sql.bz2"
dbhost="Domain"
dbname="DatenbankName"
dbuser="DatenbankBenutzer"
dbpasswd="DatenbankPasswort"
dbparm="--quick --protocol=TCP --opt -C"
#FTP
ftpsuffix="_xxx.tar.bz2"
ftphost="FTP_Host"
ftpuser="FTP_User"
ftppasswd="FTP_Passwort"
ftpdir="$ftp/$date"
ftpremotedir="/"
ftpcmd="mirror"
ftpparm="--parallel=4 --no-umask -x usage/ -x downloads/ -x old/ -X *.sql.gz -X *.sql"
#TESTS
error=0
which lftp >/dev/null || { echo "Error: lftp not found"; error=1 ;}
which tar >/dev/null || { echo "Error: tar not found"; error=1 ;}
which bzip2 >/dev/null || { echo "Error: bzip2 not found"; error=1 ;}
which mysqldump >/dev/null || { echo "Error: mysqldump not found"; error=1 ;}
[[ -d $ftp ]] || { echo "Error: The directory $ftp from \$ftp doesn't exist"; error=1 ;}
[[ -d $sql ]] || { echo "Error: The directory $sql from \$sql doesn't exist"; error=1 ;}
[[ $error == 1 ]] && exit
#CODE
while [[ $# -gt 0 ]]; do
case "$1" in
"--sql")
#sql
mysqldump $dbparm -h $dbhost -u$dbuser -p$dbpasswd $dbname | bzip2 -c9 > $sql/${date}${dbsuffix}
;;
"--ftp")
#ftp
mkdir $ftpdir
lftp -u $ftpuser:$ftppasswd -e "$ftpcmd $ftpparm $ftpremotedir $ftpdir;quit" $ftphost &> /dev/null
cd $ftp
tar -cjf $date$ftpsuffix $date
rm -Rf $ftp/$date
;;
esac
shift
done
|
This article has been read 192,365 times.
Tags: Backup, MySQL, Script, Webserver
Categories: Allgemein
Next article
by DeaD_EyE (Tuesday, March 22nd 2011, 1:54pm)
Friday, June 17th 2011, 11:43pm
Sunday, June 5th 2011, 8:42pm
Sunday, May 29th 2011, 5:37pm
Thursday, April 21st 2011, 8:13am
Tuesday, March 22nd 2011, 1:54pm
by paini (Jan 27th 2022, 10:48am)
by theJEWandI (Sep 20th 2011, 5:13am)
by zhuowu (Sep 20th 2011, 2:44am)
by pisey2002my (Sep 16th 2011, 4:09am)
by MAMYCAY (Sep 16th 2011, 3:08am)
by HSFighter Feb 8th 2011, 7:32pm