Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
Prossima revisione | Revisione precedente | ||
script_di_backup_su_ispconfig [2010/11/08 11:23] – creata luca | script_di_backup_su_ispconfig [2014/07/03 14:57] (versione attuale) – modifica esterna 127.0.0.1 | ||
---|---|---|---|
Linea 1: | Linea 1: | ||
Lo script è eseguito in / | Lo script è eseguito in / | ||
- | # | + | |
- | #DICHIARO UN ARRAY | + | #DICHIARO UN ARRAY |
- | declare -a array1 | + | declare -a array1 |
- | + | ||
- | ### System Setup ### | + | ### System Setup ### |
- | BACKUP=/ | + | BACKUP=/ |
- | NOW=$(date +" | + | NOW=$(date +" |
- | INCFILE="/ | + | INCFILE="/ |
- | DAY=$(date +" | + | DAY=$(date +" |
- | FULLBACKUP=" | + | FULLBACKUP=" |
- | + | ||
- | ### MySQL Setup ### | + | ### MySQL Setup ### |
- | MUSER=" | + | MUSER=" |
- | MPASS=" | + | MPASS=" |
- | MHOST=" | + | MHOST=" |
- | MYSQL=" | + | MYSQL=" |
- | MYSQLDUMP=" | + | MYSQLDUMP=" |
- | GZIP=" | + | GZIP=" |
- | + | ||
- | ### FTP server Setup ### | + | ### FTP server Setup ### |
- | FTPD="/ | + | FTPD="/ |
- | FTPU=" | + | FTPU=" |
- | FTPP=" | + | FTPP=" |
- | FTPS=" | + | FTPS=" |
- | NCFTP=" | + | NCFTP=" |
- | + | ||
- | #DIRECTORY DI CUI FARE IL BACKUP | + | #DIRECTORY DI CUI FARE IL BACKUP |
- | DIRECTORY="/ | + | DIRECTORY="/ |
- | #INSERIRE IL PREFIX PER COMPIARE SOLO LE CARTELLE CHE HANNO UNA DETERMINATA STRINGA# | + | #INSERIRE IL PREFIX PER COMPIARE SOLO LE CARTELLE CHE HANNO UNA DETERMINATA STRINGA# |
- | # | + | # |
- | PREFIX=" | + | PREFIX=" |
- | + | ||
- | ### Other stuff ### | + | ### Other stuff ### |
- | EMAILID=" | + | EMAILID=" |
- | + | ||
- | #FILE IN CUI SALVARE LA LISTA DELLE DIRECTORY | + | #FILE IN CUI SALVARE LA LISTA DELLE DIRECTORY |
- | FILE=.backuplist | + | FILE=.backuplist |
- | + | ||
- | if [[ $PREFIX = "" | + | if [[ $PREFIX = "" |
- | then | + | then |
- | ls $DIRECTORY | more > $FILE | + | |
- | else | + | else |
- | ls $DIRECTORY | more | grep $PREFIX > $FILE | + | |
- | fi | + | fi |
- | + | ||
- | if [ -f $FILE ]; then | + | if [ -f $FILE ]; then |
- | array1=(`cat $FILE |tr ' | + | |
- | else | + | else |
- | echo "File $FILE does not exists" | + | |
- | exit 3 | + | |
- | fi | + | fi |
- | #echo ${array1[2]} | + | #echo ${array1[2]} |
- | + | ||
- | #CONTO IL NUMERO DELLE CARTELLE | + | #CONTO IL NUMERO DELLE CARTELLE |
- | conta_elementi=${# | + | conta_elementi=${# |
- | + | ||
- | ### Start Backup for file system ### | + | ### Start Backup for file system ### |
- | [ ! -d $BACKUP ] && mkdir -p $BACKUP || : | + | [ ! -d $BACKUP ] && mkdir -p $BACKUP || : |
- | + | ||
- | if [ " | + | if [ " |
- | FTPD="/ | + | FTPD="/ |
- | COUNTER=0 | + | COUNTER=0 |
- | while [ $COUNTER -lt $conta_elementi ]; do | + | while [ $COUNTER -lt $conta_elementi ]; do |
- | DIRS=$DIRECTORY/ | + | DIRS=$DIRECTORY/ |
- | FILE=" | + | FILE=" |
- | nice -n 19 tar -zcvf $BACKUP/ | + | nice -n 19 tar -zcvf $BACKUP/ |
- | let COUNTER=COUNTER+1 | + | let COUNTER=COUNTER+1 |
+ | done | ||
+ | cp /etc/passwd $DIRECTORY/ | ||
+ | cp /etc/shadow $DIRECTORY/ | ||
+ | cp / | ||
+ | else | ||
+ | COUNTER=0 | ||
+ | while [ $COUNTER -lt $conta_elementi ]; do | ||
+ | DIRS=$DIRECTORY/ | ||
+ | i=$(date +" | ||
+ | FILE=" | ||
+ | #echo $FILE | ||
+ | TMP=$BACKUP/ | ||
+ | echo $DIRS | ||
+ | nice -n 19 tar -g $INCFILE -zcvf $TMP $DIRS | ||
+ | let COUNTER=COUNTER+1 | ||
+ | done | ||
+ | fi | ||
+ | |||
+ | ### Start MySQL Backup ### | ||
+ | # Get all databases name | ||
+ | FILE=$BACKUP/ | ||
+ | $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS --all-databases | $GZIP -9 > $FILE | ||
+ | DBS=" | ||
+ | for db in $DBS | ||
+ | do | ||
+ | | ||
+ | | ||
done | done | ||
- | | + | |
- | | + | ### Dump backup using FTP ### |
- | cp / | + | #Start FTP backup using ncftp |
- | else | + | ncftp -u" |
- | COUNTER=0 | + | mkdir $FTPD |
- | while [ $COUNTER -lt $conta_elementi ]; do | + | mkdir $FTPD/ |
- | DIRS=$DIRECTORY/ | + | cd $FTPD/ |
- | i=$(date +" | + | lcd $BACKUP |
- | FILE=" | + | mput * |
- | #echo $FILE | + | quit |
- | TMP=$BACKUP/ | + | EOF |
- | echo $DIRS | + | |
- | nice -n 19 tar -g $INCFILE -zcvf $TMP $DIRS | + | ### Find out if ftp backup failed or not ### |
- | let COUNTER=COUNTER+1 | + | if [ " |
- | done | + | |
- | fi | + | else |
- | + | | |
- | ### Start MySQL Backup ### | + | |
- | # Get all databases name | + | |
- | FILE=$BACKUP/ | + | |
- | $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS --all-databases | $GZIP -9 > $FILE | + | |
- | DBS=" | + | |
- | for db in $DBS | + | fi |
- | do | + | |
- | | + | |
- | | + | #echo $conta_elementi |
- | done | + | |
- | + | ||
- | ### Dump backup using FTP ### | + | |
- | #Start FTP backup using ncftp | + | |
- | ncftp -u" | + | |
- | mkdir $FTPD | + | |
- | mkdir $FTPD/ | + | |
- | cd $FTPD/ | + | |
- | lcd $BACKUP | + | |
- | mput * | + | |
- | quit | + | |
- | EOF | + | |
- | + | ||
- | ### Find out if ftp backup failed or not ### | + | |
- | if [ " | + | |
- | rm -f $BACKUP/* | + | |
- | else | + | |
- | | + | |
- | echo "Date: $(date)"> | + | |
- | echo " | + | |
- | echo " | + | |
- | | + | |
- | rm -f $T | + | |
- | fi | + | |
- | + | ||
- | + | ||
- | #echo $conta_elementi | + |