Backup da Área Web e Home

Description

Para fazer o backup da área web utilizamos a fita dat e o crontab. O backup esta agendado para todo dia as 02h da manhã. Incluimos no crontab:

 
[root@sprace ~]# crontab -e
00 02 * * 1-7   /bin/tar -cjvpf /dev/st0  /export/html /etc /var/www  /export/home > /dev/null 2> /root/backup.log
 
Isso irá escrever um log no /root/backup.log. Para visualizar o backup use
tar -tjvf /dev/st0

Updates

O crontab foi modificado: semanalmente (domingo) fazemos um backup full em disco (/disk1/backup-full-data_do_dia.tar.bz2), removendo o anterior para salvar espaco. Diariamente as 02h fazemos um incremental.
 
00 04 * * 1  rm /disk1/backup-full-*.tar.bz2;/bin/tar -cjvpf /disk1/backup-full-`date +DONEm%d`.tar.bz2  /export/html /etc /var/www  /export/home
00 02 * * 1-7 mt -f  /dev/st0 rewind; /bin/tar -cjvpf /dev/st0 --label="incremental-backup created on `date '+%d-%B-%Y'`." -N `date`   /export/html /etc /var/www  /export/home > /dev/null 2> /root/backup.log
 

Updates

Devido a um erro nas aspas coloquei tudo em scripts no /root/backup. Ainda foi colocada a opcao i no tar para ignorar os EOF
[root@sprace backup]# crontab -e
00 04 * * 1  /root/backup/backup_semanal.sh
00 02 * * 1-7 /root/backup/backup_diario.sh 
[root@sprace backup]# more backup_diario.sh
#!/bin/bash
mt -f  /dev/st0 rewind; /bin/tar -icjvpf /dev/st0  -N `date +DONEm%d`   /export/html /etc /var/www  /export/home/novaes > /dev/null 2> /root/backup/backup.log
[root@sprace backup]# more backup_semanal.sh
#!/bin/bash
rm /disk1/backup-full*.tar.bz2;/bin/tar -icjvpf /disk1/backup-full`date +DONEm%d`.tar.bz2  /export/html /etc /var/www  /export/home /OSG ; cd /raid0/sprace_backup;rm -rf /raid0/sprace_backup/semana1;mv /raid0/sprace_backup/semana2 /raid0/sprace_backup/semana1;mv /raid0/sprace_backup/semana3 /raid0/sprace_backup/semana2;cp -al /raid0/sprace_backup/semana4 /raid0/sprace_backup/semana3;rsync -avz --delete  /export/html /raid0/sprace_backup/semana4/;rsync -avz  /etc /raid0/sprace_backup/semana4/;rsync -avz --delete /var/www /raid0/sprace_backup/semana4/;rsync -avz  --delete /export/home /raid0/sprace_backup/semana4/;rsync -avz --delete  /OSG /raid0/sprace_backup/semana4/;

O backup é rodado no em /raid0/sprace_backup, o mais velho em semana1, feito usando o rsync.

Atualização 02/06/2008

O backup passa a ser dirigido não para o /raid0 e sim para a evo.sprace.org.br. Esta maquina aceita somente autenticação por chaves, desabilitando a autenticação por senha.
#!/bin/bash
mount /OSG; ssh evo.sprace.org.br 'cd /scratch/sprace_backup;rm -rf /scratch/sprace_backup/semana1;mv /scratch/sprace_backup/semana2 /scratch/sprace_b
ackup/semana1;mv /scratch/sprace_backup/semana3 /scratch/sprace_backup/semana2;cp -al /scratch/sprace_backup/semana4 /scratch/sprace_backup/semana3';r
sync -avz --delete  /export/html evo.sprace.org.br:/scratch/sprace_backup/semana4/;rsync -avz  /etc evo.sprace.org.br:/scratch/sprace_backup/semana4/;
rsync -avz --delete /var/www evo.sprace.org.br:/scratch/sprace_backup/semana4/;rsync -avz  --delete /export/home evo.sprace.org.br:/scratch/sprace_bac
kup/semana4/;rsync -avz --delete  /OSG evo.sprace.org.br:/scratch/sprace_backup/semana4/;umount /OSG

Atualização 26/10/2008

Para os backups do /OSG estamos usando um disco montado via nfs da access:

cd /root/backup/
vim backup_diario.sh
==============
montado=`df -h | grep /hdacs`
if [ -z "$montado" ]; then
echo "Diretorio nao montado"
exit 1
else
rsync -av --delete /opt/osg-1.0.0 /hdacs/BCKP/OSG/
rsync -avz -e "ssh -i /home/mdias/.ssh/id_rsa -l mdias" osgse:/opt/d-cache /hdacs/BCKP/dCache/
rsync -av --delete /etc /hdacs/BCKP/etc-osgce/
fi
==============
chmod +x backup_diario.sh
mkdir /hdacs/BCKP/OSG
mkdir /hdacs/BCKP/dCache
mkdir /hdacs/BCKP/etc-osgce
mkdir /hdacs/BCKP/certificados
crontab -e
00 02 * * 1-7 /root/backup/backup_diario.sh
su - mdias
ssh-keygen -t rsa
#na osg-ce
vim .ssh/authorized_keys
#copie o conteudo de .ssh/id_rsa.pub da osg-ce lá

os outros backups ainda não foram implementados (/home da spweb e área web)

Topic revision: r10 - 2008-10-26 - MarcoAndreFerreiraDias
 

This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback

antalya escort bursa escort eskisehir escort istanbul escort izmir escort