Taula de continguts

Protocol per Backup de les dades del centre

El backup es farà de manera automàtica.
Es un procés que es dispara des d'un dels servidors, el backup el fan tres procediments diferents dissenyats seguint el criteri de:

A l'arxiu /etc/crontab les següents línies de programa que dispararan el procediment adequat en el moment que es consideri oportú:

###
# DIARIA - Còpia de seguretat a les 00:00 els dimarts, dimecres, dijous, divendres i dissabtes
0  3    * * 2,3,4,5,6 root /root/backup_sh/backup_diari.sh

###
# SETMANAL - Còpia de seguretat a les 00:00 del diumenge
0  3    *    * 0         root /root/backup_sh/backup_setmanal.sh

Generació de les claus SSH

Donat que el procés es basa en el protocol SSH, i que caldria identificar les dues màquines introduint la corresponent contrasenya d'accés, cal declarar unes claus d'accés públic que identifiquin les dues màquines sense necessitat d'introduir la contrasenya. Generació de les claus SSH

Backup_diari.sh

################################################################################
# ARGO1
################################################################################

###
# Còpies diàries 
###
echo .. >> /backup/registre_backup_diari.txt
echo 'Inici de backup: '
date +'INICI backup diari: '%A' '%d' de '%B' de '%Y' a les '%H':'%M
date +'INICI backup diari: '%A' '%d' de '%B' de '%Y' a les '%H':'%M >> /backup/registre_backup_diari.txt

###
# Backup ARGO1
###

###
# Establiment dels permisos de les carpetes
###
 	ssh root@192.168.0.100 -i sh /root/procedimentsSH/permisos_carpetes.sh

###
# Configuració del sistema: ARGO1
###

###
# Arxius de configuració
	rsync -av root@192.168.0.100:/etc/auto.master /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/auto.smb /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/crontab /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/exports /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/fstab /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/ldap.conf /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/nsswitch.conf /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/rc.local /backup/Backup_Primari/argo1/etc

###
# Carpetes de configuració
	rsync -av root@192.168.0.100:/etc/apache2 /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/ldap /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/ldap-account-manager /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/pam.d /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/php5 /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/skel* /backup/Backup_Primari/argo1/etc
	rsync -av root@192.168.0.100:/etc/ssh /backup/Backup_Primari/argo1/etc

###
# Bases de dades de LDAP
	rsync -av root@192.168.0.100:/var/lib/ldap /backup/Backup_Primari/argo1/var/lib

###
# Backup dades del servidor ARGO1
###
# Còpia de les dades de G
	echo 'rsync -av root@192.168.0.100:/srv/exports/G /backup/Backup_Primari/argo1/srv/exports'
	rsync -av root@192.168.0.100:/srv/exports/G /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de direct
	echo 'rsync -av root@192.168.0.100:/srv/exports/direct /backup/Backup_Primari/argo1/srv/exports'
	rsync -av root@192.168.0.100:/srv/exports/direct /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de P
	echo 'rsync -av root@192.168.0.100:/srv/exports/P /backup/Backup_Primari/argo1/srv/exports'
	rsync -av root@192.168.0.100:/srv/exports/P /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de super
	echo 'rsync -av root@192.168.0.100:/srv/exports/super /backup/Backup_Primari/argo1/srv/exports'
	rsync -av root@192.168.0.100:/srv/exports/super /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de T
	echo 'rsync -av root@192.168.0.100:/srv/exports/T /backup/Backup_Primari/argo1/srv/exports'
	rsync -av root@192.168.0.100:/srv/exports/T /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de imatges.cd
	echo 'rsync -av root@192.168.0.100:/srv/exports/imatges.cd /backup/Backup_Primari/argo1/srv/exports'
	rsync -av root@192.168.0.100:/srv/exports/imatges.cd /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de S
	echo 'rsync -av root@192.168.0.100:/srv/exports/S /backup/Backup_Primari/argo1/srv/exports'
	rsync -av root@192.168.0.100:/srv/exports/S /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de srv2
	echo 'rsync -av root@192.168.0.100:/mnt/srv2 /backup/Backup_Primari/argo1/mnt'
	rsync -av root@192.168.0.100:/mnt/srv2 /backup/Backup_Primari/argo1/mnt

# Còpia de les dades de M
	echo 'rsync -av root@192.168.0.100:/srv/exports/M /backup/Backup_Primari/argo1/srv/exports'
	rsync -av root@192.168.0.100:/srv/exports/M /backup/Backup_Primari/argo1/srv/exports

###
# Backup dels escriptoris dels usuaris
###
	echo 'rsync -av root@192.168.0.100:/home /backup/argo1'
	rsync -av root@192.168.0.100:/home /backup/Backup_Primari/argo1
	echo 'rsync -av root@192.168.0.100:/root /backup/Backup_Primari/argo1'
	rsync -av root@192.168.0.100:/root /backup/Backup_Primari/argo1

###
# Backup TARANIS
###

###
# Configuració del sistema: TARANIS
###
	echo 'Configuració de TARANIS'
	rsync -av /etc/apache2 /backup/Backup_Primari/taranis/etc
	rsync -av /etc/mysql /backup/Backup_Primari/taranis/etc
	rsync -av /etc/network /backup/Backup_Primari/taranis/etc
	rsync -av /etc/php5 /backup/Backup_Primari/taranis/etc
	rsync -av /etc/phpmyadmin /backup/Backup_Primari/taranis/etc
	rsync -av /etc/pure-ftpd /backup/Backup_Primari/taranis/etc
	rsync -av /etc/ssh /backup/Backup_Primari/taranis/etc
	rsync -av /etc/crontab /backup/Backup_Primari/taranis/etc
	rsync -av /etc/dnsmasq.conf /backup/Backup_Primari/taranis/etc
	rsync -av /etc/exports /backup/Backup_Primari/taranis/etc
	rsync -av /etc/fstab /backup/Backup_Primari/taranis/etc
	rsync -av /etc/hostname /backup/Backup_Primari/taranis/etc
	rsync -av /etc/hosts /backup/Backup_Primari/taranis/etc
	rsync -av /etc/rc.local /backup/Backup_Primari/taranis/etc
	rsync -av /etc/auto.master /backup/Backup_Primari/taranis/etc
	rsync -av /etc/auto.smb /backup/Backup_Primari/taranis/etc
	rsync -av /etc/nsswitch.conf /backup/Backup_Primari/taranis/etc
	rsync -av /etc/ldap /backup/Backup_Primari/taranis/etc
	rsync -av /etc/pam.d /backup/Backup_Primari/taranis/etc
	rsync -av /etc/skel* /backup/Backup_Primari/taranis/etc

###
# Arxius del servidor /srv
###
	echo 'rsync -av /srv /backup/Backup_Primari/taranis'
	rsync -av /srv /backup/Backup_Primari/taranis

###
# Bases de dades
###
	echo 'rsync -av /var/lib/mysql /backup/Backup_Primari/taranis/var/lib'
	rsync -av /var/lib/mysql /backup/Backup_Primari/taranis/var/lib

###
# Carpeta de Root
###
	echo 'rsync -av /root /backup/Backup_Primari/taranis'
	rsync -av /root /backup/Backup_Primari/taranis

echo ..
echo ..
echo 'Final de backup'
date +'Final backup diari: '%A' '%d' de '%B' de '%Y' a les '%H':'%M
date +'FINAL backup diari: '%A' '%d' de '%B' de '%Y' a les '%H':'%M >> /backup/registre_backup_diari.txt
echo .. >> /backup/registre_backup_diari.txt

backup_setmanal.sh

################################################################################
# ARGO1
################################################################################

###
# Generació de la segona còpia de seguretat
###
echo ..  >> /backup/registre_backup_setmanal.txt
date +'Inici Segona Còpia de seguretat: '%A' '%d' de '%B' de '%Y' a les '%H':'%M
date +'Inici Segona Còpia de seguretat: '%A' '%d' de '%B' de '%Y' a les '%H':'%M >> /backup/registre_backup_setmanal.txt

###
# Establiment dels permisos de les carpetes
###
	echo 'ssh root@192.168.0.100 -i sh /root/procedimentsSH/permisos_carpetes.sh'
	ssh root@192.168.0.100 -i sh /root/procedimentsSH/permisos_carpetes.sh

###
#  Sincronització de la segona còpia de Backup del sistema
###

#  Línies comentades mentre no es disposi d'un segon disc dur per a fer la còpia secundària
	echo 'rsync -av --delete /backup/Backup_Primari/ /backup2/Backup_Secundari/'
 	rsync -av --delete /backup/Backup_Primari/ /backup2/Backup_Secundari/

###
# Configuració del sistema: ARGO1
###
	echo 'Actualització de la còpia primària de Backups'

###
# Arxius de configuració
	rsync -av --delete root@192.168.0.100:/etc/auto.master /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/auto.smb /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/crontab /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/exports /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/fstab /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/ldap.conf /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/nsswitch.conf /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/rc.local /backup/Backup_Primari/argo1/etc

###
# Carpetes de configuració
	rsync -av --delete root@192.168.0.100:/etc/apache2 /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/ldap /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/ldap-account-manager /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/pam.d /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/php5 /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/skel* /backup/Backup_Primari/argo1/etc
	rsync -av --delete root@192.168.0.100:/etc/ssh /backup/Backup_Primari/argo1/etc

###
# Bases de dades de LDAP
	rsync -av --delete root@192.168.0.100:/var/lib/ldap /backup/Backup_Primari/argo1/var/lib

###
# Backup dades del servidor ARGO1
###
# Còpia de les dades de G
	echo 'rsync -av --delete root@192.168.0.100:/srv/exports/G /backup/Backup_Primari/argo1/srv/exports'
	rsync -av --delete root@192.168.0.100:/srv/exports/G /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de direct
	echo 'rsync -av --delete root@192.168.0.100:/srv/exports/direct /backup/Backup_Primari/argo1/srv/exports'
	rsync -av --delete root@192.168.0.100:/srv/exports/direct /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de P
	echo 'rsync -av --delete root@192.168.0.100:/srv/exports/P /backup/Backup_Primari/argo1/srv/exports'
	rsync -av --delete root@192.168.0.100:/srv/exports/P /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de super
	echo 'rsync -av --delete root@192.168.0.100:/srv/exports/super /backup/Backup_Primari/argo1/srv/exports'
	rsync -av --delete root@192.168.0.100:/srv/exports/super /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de T
	echo 'rsync -av --delete root@192.168.0.100:/srv/exports/T /backup/Backup_Primari/argo1/srv/exports'
	rsync -av --delete root@192.168.0.100:/srv/exports/T /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de imatges.cd
	echo 'rsync -av --delete root@192.168.0.100:/srv/exports/imatges.cd /backup/Backup_Primari/argo1/srv/exports'
	rsync -av --delete root@192.168.0.100:/srv/exports/imatges.cd /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de S
	echo 'rsync -av --delete root@192.168.0.100:/srv/exports/S /backup/Backup_Primari/argo1/srv/exports'
	rsync -av --delete root@192.168.0.100:/srv/exports/S /backup/Backup_Primari/argo1/srv/exports

# Còpia de les dades de srv2
	echo 'rsync -av root@192.168.0.100:/mnt/srv2 /backup/Backup_Primari/argo1/mnt'
	rsync -av --delete root@192.168.0.100:/mnt/srv2 /backup/Backup_Primari/argo1/mnt

# Còpia de les dades de M
	echo 'rsync -av --delete root@192.168.0.100:/srv/exports/M /backup/Backup_Primari/argo1/srv/exports'
	rsync -av --delete root@192.168.0.100:/srv/exports/M /backup/Backup_Primari/argo1/srv/exports

###
# Backup dels escriptoris dels usuaris
###
	echo 'rsync -av --delete root@192.168.0.100:/home /backup/argo1'
	rsync -av --delete root@192.168.0.100:/home /backup/Backup_Primari/argo1
	echo 'rsync -av --delete root@192.168.0.100:/root /backup/Backup_Primari/argo1'
	rsync -av --delete root@192.168.0.100:/root /backup/Backup_Primari/argo1

###
# Backup TARANIS
###

###
# Configuració del sistema: TARANIS
###
	echo 'Configuració de TARANIS'
	rsync -av --delete /etc/apache2 /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/mysql /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/network /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/php5 /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/phpmyadmin /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/pure-ftpd /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/ssh /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/crontab /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/dnsmasq.conf /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/exports /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/fstab /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/hostname /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/hosts /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/rc.local /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/auto.master /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/auto.smb /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/nsswitch.conf /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/ldap /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/pam.d /backup/Backup_Primari/taranis/etc
	rsync -av --delete /etc/skel* /backup/Backup_Primari/taranis/etc

###
# Arxius del servidor /srv
###
	echo 'rsync -av --delete /srv /backup/Backup_Primari/taranis'
	rsync -av --delete /srv /backup/Backup_Primari/taranis

###
# Bases de dades
###
	echo 'rsync -av --delete /var/lib/mysql /backup/Backup_Primari/taranis/var/lib'
	rsync -av --delete /var/lib/mysql /backup/Backup_Primari/taranis/var/lib

###
# Carpeta de Root
###
	echo 'rsync -av --delete /root /backup/Backup_Primari/taranis'
	rsync -av --delete /root /backup/Backup_Primari/taranis

echo ..
echo ..
echo 'Final de backup'
date +'Final backup setmanal: '%A' '%d' de '%B' de '%Y' a les '%H':'%M
date +'Final backup setmanal: '%A' '%d' de '%B' de '%Y' a les '%H':'%M >> /backup/registre_backup_setmanal.txt
echo ..  >> /backup/registre_backup_setmanal.txt