Una forma de hacer backups con TAR

Anteriormente he utilizado alguna que otra herramienta de backups con muy buenos resultados.

Durante mucho tiempo utilicé AMANDA y la verdad es que funciona perfectamente. No os podeis imaginar lo buena que era esta herramienta con un Pentium II y varios discos grandes.

Hace unos meses en casa instalé backuppc y también me gustó mucho. Es una herramienta que gestiona multiples maneras de hacer backups con un interface web muy logrado y de una forma muy sencilla. Para aquellos que tengais varios ordenadores en casa y con sistemas diferentes la verdad es que es muy recomendable.

Por esas cosas de la vida, el disco donde tenía el SO, cascó: es lo que tienen estos aparatos y harto de instalar aplicaciones he buscado un script que me hiciera la vida fácil.

Buscando con Google he encontrado en la página Securing and Optimizing Linux el siguiente script:

#!/bin/sh
# full and incremental backup script
# created 07 February 2000
# Based on a script by Daniel O’Callaghan
# and modified by Gerhard Mourani
# Change the 5 variables below to fit your computer backup

COMPUTER=deep # name of this computer
DIRECTORIES=”/home” # directoris to backup
BACKUPDIR=/backups # where to store the backups
TIMEDIR=/backups/last-full # where to store time of full backup
TAR=/bin/tar # name and locaction of tar

#You should not have to change anything below here

PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b` # Date and Month e.g. 27Sep

# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made – overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = “”, then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.

# Monthly full backup
if [ $DOM = “01” ]; then
NEWER=””
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES
fi

# Weekly full backup
if [ $DOW = “Sun” ]; then
NEWER=””
NOW=`date +%d-%b`

# Update full backup date
echo $NOW > $TIMEDIR/$COMPUTER-full-date
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES

# Make incremental backup – overwrite last weeks
else

# Get date of last full backup
NEWER=”–newer `cat $TIMEDIR/$COMPUTER-full-date`”
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES
fi

La verdad es que os recomiendo visitar la página donde explica paso por paso como configurarlo en el propio cron y como hacer para que empieze a realizar los backups.

Enjoy!!!

Leave a comment