Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Bash by registered user britodfbr ( 12 years ago )
#/bin/bash
_help(){ 
cat << fim
Autor: 
    Ricardo Brito do Nascimento

Email: 
    britodfbr[at]gmail.com

Descrição: 
    Este script realiza o backup via repozo 
       do plone versão3 ou superior;
       pode ser utilizado para realizar 
       backups de versões anteriores
       mas será necessário customização para 
       funcionar adequadamente.
    Além do backup realiza controle de 
       retenção do backup, excluindo automaticamente
       os arquivos antigos.
    
Variáveis de configuração:
    DAYS - dias de retenção;
    FILESTORAGEDIR - diretório que contém .fs;
    BACKUPDIR - diretório que os backups 
     serão mantidos;
    EXCEPTION[n] - diretórios ou arquivos 
     que terão validade ignorada;

Execução: 
    $0; ou
    $0 -h | --help | ?
fim
}
########### Variavéis de configuração ########
DAYS=2
FILESTORAGEDIR=/opt/p335/ambienteProd/*/var/filestorage/
BACKUPDIR=/storage-bkp
EXCEPTION[0]=".snapshot"
EXCEPTION[1]="arquivosAnexos"
EXCEPTION[2]="none"
EXCEPTION[3]="none"

###########  Versão de testes ################
#/bin/find /opt/p335/*/var/filestorage/ \
-type f -name "*.fs" -printf '%h %f\n'\
|while read a b; do A=/storage-bkp/; \
B=$(awk -F/ '{print $4}' <<< ${a}); \
C=${b%.fs}; mkdir -pv ${A}/${B}/${C}; \
/opt/p335/${B}/bin/repozo -BFvzf ${a}/${b} \
-r ${A}/${B}/${C}; done
#
#/bin/find /storage-bkp/ -type f \
-atime +2 |grep -v .snapshot|xargs rm -vf


###########  Funções ################
_erro(){
cat << fim
opção inválida, consulte o help, com as opções --help ou, -h ou, ?.
fim
}
_repozoBackup(){
/bin/find $FILESTORAGEDIR -type f -name "*.fs" -printf '%h %f\n'|while read a b; do A=$BACKUPDIR; B=$(awk -F/ '{print $4"/"$5}' <<< ${a}); C=${b%.fs}; mkdir -pv ${A}/${B}/${C}; /opt/p335/${B}/bin/repozo -BFvzf ${a}/${b} -r ${A}/${B}/${C}; done
}
_removeOld(){
/bin/find $BACKUPDIR \( -ctime +${DAYS} -o -atime +${DAYS} -o -mtime +${DAYS} \)|grep -v ${EXCEPTION[0]}|grep -v ${EXCEPTION[1]}|grep -v ${EXCEPTION[2]}|grep -v ${EXCEPTION[3]} |xargs rm -vrf
}
_start(){
_repozoBackup
_removeOld
}
_stop(){
_erro;
}
_restart(){
_erro
}
_status(){
_erro
}

case $1 in
        start) _erro;;
        stop) _stop;;
        status) _status;;
        restart) _restart;;
        -h|--help|?) _help;;
        '') _start;;
        *) _erro ;;
esac

 

Revise this Paste

Your Name: Code Language: