Autor Tópico: Script de backup em hd externo  (Lida 2554 vezes)

Offline linuxeopoder

  • Usuário Ubuntu
  • *
  • Mensagens: 10
    • Ver perfil
Script de backup em hd externo
« Online: 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



Offline Tota

  • Usuário Ubuntu
  • *
  • Mensagens: 14.982
    • Ver perfil
Re: Script de backup em hd externo
« Resposta #1 Online: 30 de Abril de 2012, 10:15 »
Ola

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

[]'s

Offline linuxeopoder

  • Usuário Ubuntu
  • *
  • Mensagens: 10
    • Ver perfil
Re: Script de backup em hd externo
« Resposta #2 Online: 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.

Offline web2000

  • Usuário Ubuntu
  • *
  • Mensagens: 360
  • Rafael A. de Almeida
    • Ver perfil
    • Meu canal no YouTube
Re: Script de backup em hd externo
« Resposta #3 Online: 30 de Abril de 2012, 13:26 »
Boa tarde a todos!  :o

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: [Selecionar]
#!/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: [Selecionar]
#!/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: [Selecionar]
#!/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 »

Offline linuxeopoder

  • Usuário Ubuntu
  • *
  • Mensagens: 10
    • Ver perfil
Re: Script de backup em hd externo
« Resposta #4 Online: 30 de Abril de 2012, 14:20 »
Vlw web2000.
Foi de ótima ajuda o seu script. Já consegui fazer o backup usando seu script.