removido
(usa Nenhuma)
Enviado em 22/04/2011 - 00:51h
ja estou com tudo configurado, mas tenho certeza que vou ter problemas na organização de diretorios, mas isso vou resolver em outro topico
rsyncd.conf -----------------------------
#
# /etc/rsyncd.conf
#
# Usuário sob o qual o rsync irá rodar
uid=root
# Grupo sob o qual o rsync irá rodar
gid=root
# Arquivo de log
log file = /var/log/rsyncd.log
# Módulo para o servidor-um
[FreeBSD-center]
# Caminho onde fica o espaço para este módulo
path = /backup/current/FreeBSD-center
# Usuário(s) autorizado(s)
auth users = backup
# Arquivo de usuários senhas
secrets file = /etc/rsyncd.secrets
# Permitir gravação
read only = false
# Não incluir este módulo quando solicitada a listagem
list = false
# IP(s) ou rede permitidos a conectar
hosts allow = 192.168.2.1
# Log de Transferências
transfer logging = yes
# Formato do arquivo de log
log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
# Módulo para o servidor-dois.
[FreeBSD-server]
path = /backup/current/FreeBSD-server
auth users = backup
secrets file = /etc/rsyncd.secrets
read only = false
list = false
hosts allow = 192.168.2.2
transfer logging = yes
log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
-----------------------------------------------------------
dgfbackupserver -------------------------------------------
#!/bin/sh
TAR="/usr/bin/tar"
TAR_FLAGS="-cjvf"
PATH_CURRENT=/backup/current
PATH_FULL=/backup/full
PATH_INCREMENTAL=/backup/incremental
NAME_FLAGS=""
LOG_DIR="/var/log/backup"
mkdir -p $LOG_DIR $PATH_INCREMENTAL $PATH_FULL $PATH_CURRENT
TYPE=$(echo $1 | tr [A-Z] [a-z])
case $TYPE in
full)
TAR_FLAGS+=""
PATH="$PATH_FULL"
NAME_FLAGS+=""
;;
incremental)
TAR_FLAGS+=""
PATH="$PATH_INCREMENTAL"
NAME_FLAGS+="_$(date +%Y-%m-%d_%H:%M)"
;;
esac
LOG="$LOG_DIR/${TYPE}_$(date +%Y-%m-%d).log"
NAME="$PATH/*"
echo "###############== START - $(date %H:%M) ==###############" >> $LOG
for i in $NAME; do
PKGBKP="$NAME$NAME_FLAGS.tar.bz2"
echo "$NAME - Start $(date %H:%M)" >> $LOG
$TAR $TAR_FLAGS $NAME -C $PATH/$PKGBKP >> $LOG
echo "$NAME - Stop $(date %H:%M)" >> $LOG
echo "" >> $LOG
done
echo "###############== FINISH - $(date %H:%M) ==###############" >> $LOG
echo "" >> $LOG
mv $LOG $LOG_$(date +%Y-%m-%d)
------------------------------------------------------------------
dgfbackupclient ---------------------------------------------------
#!/bin/sh
SSH="/usr/bin/ssh"
RSYNC="/usr/bin/rsync"
RSYNC_FLAGS="--skip-compress=gz/tgz/jpg/jpeg/mp[34]/7z/bz2"
LOG_DIR="/var/log/backup"
LOG="$LOG_DIR/$(date +%Y-%m-%d).log"
mkdir -p $LOG_DIR
BACKUP() {
TRANSMISSION=$(echo $1 | tr [A-Z] [a-z])
case $TRANSMISSION in
rsync)
RSYNC_FLAGS+=" -Cravzp"
HOST="$2"
USER="$3"
LPATH="$4"
MODULE="$5"
DEST="$USER@$HOST::$MODULE"
;;
ssh)
RSYNC_FLAGS+=" -Cravzp -e ssh"
HOST="$2"
USER="$3"
LPATH="$4"
RPATH="$5"
DEST="$USER@$HOST:$RPATH $LPATH"
;;
esac
echo "###############== START - $(date %H:%M) ==###############" >> $LOG
for i in $LPATH; do
echo "$LPATH - Start $(date %H:%M)" >> $LOG
$RSYNC $RSYNC_FLAGS $DEST >> $LOG
echo "$LPATH - Stop $(date %H:%M)" >> $LOG
echo "" >> $LOG
done
echo "###############== FINISH - $(date %H:%M) ==###############" >> $LOG
echo "" >> $LOG
mv $LOG $LOG_$(date +%Y-%m-%d)
}
### RSYNC
# BACKUP "TRANSMISSION" "REMOTE-IP" "USER" "DIR(s)" "MODULE"(rsyncd.conf)
# BACKUP "rsync" "192.168.2.3" "backup" "/mnt/dados /home/user" "FreeBSD-center"
### SSH
# BACKUP "TRANSMISSION" "REMOTE-IP" "USER" "DIR(s)" "REMOTE-DIR"
# BACKUP "ssh" "192.168.2.3" "backup" "/mnt/dados /home/user" "/backup"
BACKUP "ssh" "192.168.2.3" "backup" "/mnt/rede" "/backup/current/FreeBSD-center"
------------------------------------------------------------------
agr só falta jogar o find no script dgfbackupserver, vlw