Fórum Ubuntu Linux - PT
24 de Maio de 2013, 01:20 *
Olá, Visitante. Faça o login ou registre-se.
Perdeu o seu e-mail de ativação?

Login com nome de usuário, senha e duração da sessão
Notícias: Atenção usuários de email com anti-spam (Uol e Bol).
 
   Home   Ajuda Regras Pesquisa Login Registre-se  
Anúncios
Páginas: [1]   Ir para o fundo
  Imprimir  
Autor Tópico: Script de backup em hd externo  (Lida 735 vezes)
linuxeopoder
Usuário Ubuntu
*
Deslogado Deslogado

Mensagens: 10


Ver Perfil
« em: 30 de Abril de 2012, 09:49 »

Olá pessoal, sou iniciante e gostaria de uma imensa ajuda.
Gostaria de criar um Script de Backup para ser realizado em um HD externo com montagem e desmontagem apos o backup com Rsync de segunda a sexta feira.
O horário de backup será realizado as 23:00.

HD Externo = sdb1


Registrado
Tota
Usuário Ubuntu
*
Deslogado Deslogado

Mensagens: 11.705



Ver Perfil
« Responder #1 em: 30 de Abril de 2012, 10:15 »

Ola

Poste o que já fez no seu script para o forum ajudar com mais entusuasmo.

[]'s
Registrado
linuxeopoder
Usuário Ubuntu
*
Deslogado Deslogado

Mensagens: 10


Ver Perfil
« Responder #2 em: 30 de Abril de 2012, 12:56 »

Ola

Poste o que já fez no seu script para o forum ajudar com mais entusuasmo.

[]'s

quero um script do zero.
Registrado
web2000
Usuário Ubuntu
*
Deslogado Deslogado

Mensagens: 360


Rafael A. de Almeida


Ver Perfil WWW
« Responder #3 em: 30 de Abril de 2012, 13:26 »

Boa tarde a todos!  Chocado

Segue abaixo meu script pessoal para backup. Com ele você pode recuperar seus aquivos como eles eram em uma determinada data. Isso não ocupa muito espaço adicional, pois usa hard links. O backup é feito todas as vezes em que o computador é ligado (isso não deixa lento, com o passar dos dias).

Até+

Rafael


Citar
Copyright © 2012 Rafael Abreu de Almeida <rafael.kbps@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/etc/rc.local
Código:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

'/home/rafael/Projetos/2012/backup.sh' &

exit 0

/home/rafael/Projetos/2012/backup.sh
Código:
#!/bin/bash
# Copyright © 2012 Rafael Abreu de Almeida <rafael.kbps@gmail.com>

sleep 330

umount /mnt
umount /dev/sdb1
mount /dev/sdb1 /mnt

/mnt/lamp/backup.sh

sudo umount /mnt

/mnt/lamp/backup.sh
Código:
#!/bin/bash
# Copyright © 2012 Rafael Abreu de Almeida <rafael.kbps@gmail.com>

BackupDir='/mnt/lamp'
CurrentDate=`date +'%Y-%m-%d'`

mysqldump -u root --password=SUA_SENHA_AQUI --all-databases > /var/www/backup-mysql
chown -R rafael:rafael /home/rafael/

sudo rsync \
-Cav \
--exclude=/proc/ \
--exclude=/sys/ \
--exclude=/dev/ \
--delete-excluded \
$Source:/ \
$BackupDir/current/

sudo rsync -Cavz \
--delete-excluded \
--exclude '.gvfs' \
/etc/ $BackupDir/current/etc/

sudo rsync -Cavz \
--delete-excluded \
--exclude '.gvfs' \
/var/www/ $BackupDir/current/var/www/

sudo rsync -Cavz \
--delete-excluded \
--exclude '.gvfs' \
--exclude '.VirtualBox VMs' \
--exclude 'google-chrome/' \
--exclude '.mozilla/firefox' \
--exclude 'Downloads/'  \
--exclude '.local/share/' \
--exclude 'home/' \
/home/rafael/ $BackupDir/current/home/rafael/

sudo rm -r $BackupDir/$CurrentDate
sudo cp -al $BackupDir/current/ $BackupDir/$CurrentDate/
« Última modificação: 30 de Abril de 2012, 13:31 por web2000 » Registrado

linuxeopoder
Usuário Ubuntu
*
Deslogado Deslogado

Mensagens: 10


Ver Perfil
« Responder #4 em: 30 de Abril de 2012, 14:20 »

Vlw web2000.
Foi de ótima ajuda o seu script. Já consegui fazer o backup usando seu script.
Registrado
Páginas: [1]   Ir para o topo
  Imprimir  
 
Ir para:  

Powered by MySQL Powered by PHP Tema desenvolvido por FaBMak e n3t0
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines
© 2013 Canonical Ltd. Ubuntu e Canonical são marcas registradas da Canonical Ltd.
XHTML 1.0 válido! CSS válido!