UNIX NetWork

Software, Shell ScriptingSeptember 20, 2008 4:57 pm

#!/bin/bash
#### Script para respaldar Servidor ####

##### Modifique estas variables #####
#Directorio a donde se almacenaran los respaldos
Backup=/Ruta/donde/se/guarda/el/respaldo
#Nombre o IP del equipo
Equipo=Conta1
#Directorio compartido a respaldar
Share=”Mis_doctos”
#Tamano maximo del respaldo en MB
Maximo=900
#Dia para hacer respaldos completo (lunes a viernes)
DiaCompleto=”1″
####################################

#### Comprobar o crear Directorios ####
if [ ! -d $Backup ]; then mkdir $Backup; fi
####
if [ ! -d $Backup/$Equipo ]; then mkdir $Backup/$Equipo; fi
#######################################

Fecha=`date -I`
cd $Backup/$Equipo

################## RESPALDO ######################
### Montando ###
if [ ! -d $Share ]; then mkdir $Share; fi
echo ” ”
echo -e “Montando unidad de red \033[2;32m$Share\033[0;0m de \033[2;34m$Equipo\033[0;0m”
mount -t smbfs -o username=usuario,password=pasguord //$Equipo/$Share $Share
################

####### Analizando espacio en Share #########
Size=`du -ms $Share | awk ‘{ print $1 }’`

# Este if es por si el tamano del Share sobrepasa el limite
if [ $Size -lt $Maximo ]
then
echo -e “El tamano de \033[2;32m$Share\033[0;0m es: \033[2;34m$Size MB\033[0;0m”
else
echo -e “\033[2;32m$Share\033[0;0m es mayor a \033[5;31m$Maximo MB\033[0;0m”
### Desmontando ###
umount $Share
rmdir $Share
###################
exit 0
fi

# Este if es por si al intentar montar el share no existe.
if [ $Size -gt 2 ]
then
DIA=`date +%u`
if [ $DIA = $DiaCompleto ]
then
### Respaldando COMPLETO ###
echo -e “Respaldando \033[5;31m$Equipo/$Share…\033[0;0m Completo”
tar cfz $Backup/$Equipo/$Share”_”$Fecha.tgz “$Share”
###################
### Desmontando ###
umount $Share
rmdir $Share
###################
exit 0
else
### Respaldando INCREMENTAL ###
echo -e “Respaldando \033[5;31m$Equipo/$Share…\033[0;0m Incremental”
tar –newer `date -I -d yesterday` -zcf $Share”_”$Fecha.tgz “$Share”
###################
### Desmontando ###
umount $Share
rmdir $Share
###################
exit 0
fi
else
###################
echo ” ”
echo ” ”
echo -e “\033[5;31mRevise sus Variables!!!\033[0;0m”
echo ” ”
echo ” ”
### Desmontando ###
rmdir $Share
###################
exit 0
fi
###############################################
#####################################################

thanks to Montecristo

Shell ScriptingNovember 25, 2007 6:26 am

#!/bin/sh
# Backup all files under home directory to a single # floppy
# Display message with option to cancel
dialog –title “Backup” –msgbox “Time for backup \ of home directory. \
Insert formatted 3-1/2\” floppy and press \ to start backup or \
to cancel.” 10 50
# Return status of non-zero indicates cancel
if [ “$?” != “0″ ]
then
dialog –title “Backup” –msgbox “Backup was \ canceled at your
request.” 10 50
else
dialog –title “Backup” –infobox “Backup in \ process…” 10 50
cd ~
# Backup using tar; redirect any errors to a
# temporary file
# For multi-disk support, you can use the
# -M option to tar
tar -czf /dev/fd1 . >|/tmp/ERRORS$$ 2>&1
# zero status indicates backup was successful
if [ “$?” = “0″ ]
then
dialog –title “Backup” –msgbox “Backup \
completed successfully.” 10 50
# Mark script with current date and time
touch ~/.backup
else
# Backup failed, display error log
dialog –title “Backup” –msgbox “Backup failed \ — Press

to see error log.” 10 50
dialog –title “Error Log” –textbox /tmp/ERRORS$$ 22 72
fi
fi
rm -f /tmp/ERRORS$$
clear
To run this automatically, I put these lines in my .profile file to call the backup script on login if more than 3 days has elapsed since the last backup was made:

# do a backup if enough time has elapsed
find ~/.backup -mtime +3 -exec ~/.backup \;

Shell Scripting 6:11 am

#!/bin/bash

#Author: Jamil De Jesus Enríquez Deceano
#Date: Saturday 24 November 2007
#License: GPL

cd /home/kukako
for ((i=1; i< =6; i++))
do
echo "BEGIN DOWNLOAD DISCO $i CENTOS 5"
echo
wget -d -r -c http://altruistic.lbl.gov/mirrors/centos/5.0/isos/i386/CentOS-5.0-i386-bin-"$i"of6.iso
done
echo "Finish download Centos 5 completed !!!"
exit 0