Backup Facil e rapido

Publicado por Iuri Carraro 19/04/2005

[ Hits: 7.062 ]

Download backup.sh




Este backup mantei 2 copias do backup para que não haja riscos de haver um backup com dados errados.

  



Esconder código-fonte

#######################################################################################
#!/bin/bash                                                                           #
# Script de backup                                                                    #
# Autor: Iuri Carraro (Malamen)                                                       #
# Visite: www.vivaolinux.com.br                                                       #
# Criacao: 18/04/2005 - 16:56:58                                                      #
# Reportar erros: iuri.carraro@gmail.com                                              #
#######################################################################################
clear
echo "+------------------------------------------------------------------------------+"
echo "|                     PROGRAMA DE BACKUP - Houston                             |"
echo "+------------------------------------------------------------------------------+"
echo "|Para abortar o processos pressione [Ctrl + C] em qualquer momento.            |"
echo "+------------------------------------------------------------------------------+"
echo "|ATENÇÃO: As partes do processo que já foram realizadas não serão recuperadas  |"
echo "|após o aborto do processo.                                                    |"
echo "+------------------------------------------------------------------------------+"
echo "|Você terá 10 segundos para cancelar este programa antes que ele inicie.       |"
echo "+------------------------------------------------------------------------------+"
sleep 5
for i in 1 2 3 4 5 6 7 8 9 10 ; do
  echo -ne "{FONTE}33[G{FONTE}33[@#{FONTE}33[11G{FONTE}33[0K $i segundos"
  sleep 1
done;
echo
echo "Iniciando programa de backup."
echo "Preparando arquivos para backup..."
echo
sleep 2
echo "+------------------------------------------------------------------------------+"
echo "|                     PROGRAMA DE BACKUP - Houston - REMOVE                    |"
echo "+------------------------------------------------------------------------------+"
echo "Removendo backup e logs mais antigo..."
rm -f /mnt/backup/php.older.tar.gz
rm -f /mnt/backup/mysql.older.tar.gz
rm -f /mnt/backup/teleduc.older.tar.gz
rm -f /mnt/backup/php.older.log
rm -f /mnt/backup/mysql.older.log
rm -f /mnt/backup/teleduc.older.log
echo "Backup antigo removido com sucesso."
echo
sleep 2
echo "+------------------------------------------------------------------------------+"
echo "|                     PROGRAMA DE BACKUP - Houston - PROTECTION                |"
echo "+------------------------------------------------------------------------------+"
echo "Salvando backup e logs anterior..."
mv /mnt/backup/php.backup.tar.gz /mnt/backup/php.older.tar.gz
mv /mnt/backup/mysql.backup.tar.gz /mnt/backup/mysql.older.tar.gz
mv /mnt/backup/teleduc.backup.tar.gz /mnt/backup/teleduc.older.tar.gz
mv /mnt/backup/php.backup.log /mnt/backup/php.older.log
mv /mnt/backup/mysql.backup.log /mnt/backup/mysql.older.log
mv /mnt/backup/teleduc.backup.log /mnt/backup/teleduc.older.log
echo "Backup anterior salvo."
echo
sleep 2
echo "+------------------------------------------------------------------------------+"
echo "|                     PROGRAMA DE BACKUP - Houston - COMPRESSION               |"
echo "+------------------------------------------------------------------------------+"
echo "Compactando arquivos e gerando logs de backup..."
echo "Campactando PHP..."
tar -czvf /var/www/default/php.tar.gz /var/www/default/* > /var/www/default/php.backup.log
echo "PHP campactado."
echo 
echo "Campactando MySQL..."
tar -czvf /var/www/default/mysql.tar.gz /var/lib/mysql/* > /var/www/default/mysql.backup.log
echo "MySQL campactado."
echo
echo "Campactando Teleduc..."
tar -czvf /var/www/default/teleduc.tar.gz /home/teleduc/* > /var/www/default/teleduc.backup.log
echo "Teleduc campactado."
echo "Arquivos compactados com sucesso."
echo
sleep 2
echo "+------------------------------------------------------------------------------+"
echo "|                     PROGRAMA DE BACKUP - Houston - BACKUP                    |"
echo "+------------------------------------------------------------------------------+"
echo "Salvando backups e logs na Unidade de Backups..."
echo "Movendo backup e log PHP..."
mv /var/www/default/php.tar.gz /mnt/backup/php.backup.tar.gz
mv /var/www/default/php.backup.log /mnt/backup/php.backup.log
echo "Movendo backup e log MySQL..."
mv /var/www/default/mysql.tar.gz /mnt/backup/mysql.backup.tar.gz
mv /var/www/default/mysql.backup.log /mnt/backup/mysql.backup.log
echo "Movendo backup e log Teleduc..."
mv /var/www/default/teleduc.tar.gz /mnt/backup/teleduc.backup.tar.gz
mv /var/www/default/teleduc.backup.log /mnt/backup/teleduc.backup.log
echo "Copiando arquivos de configuração..."
cp -f /etc/fstab /mnt/backup/conf
cp -f /etc/apache/conf/httpd.conf /mnt/backup/conf
cp -f /etc/samba/smb.conf /mnt/backup/conf
cp -f /etc/php.ini /mnt/backup/conf
cp -f /etc/proftpd.conf /mnt/backup/conf
cp -f /etc/apt/sources.list /mnt/backup/conf
cp -f /boot/grub/menu.lst /mnt/backup/conf
echo "Backups movidos e copiados com sucesso."
for i in 1 2 3 4 5 6 7 8 9 10 ; do
  echo -ne "{FONTE}33[G{FONTE}33[@#{FONTE}33[11G{FONTE}33[0K $i segundos"
  sleep 1
done;
clear
echo "+------------------------------------------------------------------------------+"
echo "|                     PROGRAMA DE BACKUP - Houston                             |"
echo "+------------------------------------------------------------------------------+"
echo "|O Programa Houston foi executado com sucesso.                                 |"
echo "|Arquivos de backup estão em /mnt/backup                                       |"
echo "|Caso tenha ocorrido algum erro verifique os logs de backup no mesmo diretório.|"
echo "|Autor: Iuri Carraro                                                           |"
echo "|Criado: 18/04/2005 - 16:56:58                                                 |"
echo "|Modificado: 19/04/2005 - 11:42:17                                             |"
echo "|Reportar erros: iuri.carraro@gmail.com                                        |"
echo "+------------------------------------------------------------------------------+"

Scripts recomendados

Backup Incremental

xmms+bitchx

ADMINISTRANDO USUARIOS COM XDIALOG

Reconexão automática para internet ADSL

Converter Imagens e Documentos para PDF


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts