#!/bin/bash #FOLDER CONFIG export FOLDERS="bin sbin boot etc root media tmp proc compartir dev mnt server srv sys cdrom dvd floppy" export BIGFOLDERS="usr opt home lib var" export DEST="/mystore/gentoo" export REALLYBIGFOLDERS="usr/portage lib/modules usr/local usr/src usr/share usr/X11R6 usr/loki opt/kde3 usr/kde usr/lib" #DO THE WORK echo "BACKUP de los archivos RAIZ" find -type f -maxdepth 1 -not -name . | while read i do tar -cv "$i" | gzip -f9> "$DEST"/barra-files-`echo $i | awk -F / '{print $NF}'`.tgz done find -type l -maxdepth 1 -not -name . | while read i do tar -cv "$i" | gzip -f9> "$DEST"/barra-sym-`echo $i | awk -F / '{print $NF}'`.tgz done for DIR in $FOLDERS do echo "Backup de $DIR en $DEST/$DIR.tgz" tar -cv "$DIR" | gzip -f9 > $DEST/$DIR.tgz done for BIGDIR in $BIGFOLDERS do #Enlaces simbolicos en los directorios ralmente grandes find $BIGDIR -maxdepth 1 -type l -or -type f > $DEST/bigfolders.tmp tar --files-from=$DEST/bigfolders.tmp -cv | gzip -f9 > $DEST/$BIGDIR-1-files-links.tgz rm $DEST/bigfolders.tmp #Revisar las carpetas completas find $BIGDIR -maxdepth 1 -type d -not -name $BIGDIR | while read DIR do if echo "$REALLYBIGFOLDERS" | grep "$DIR" > /dev/null; then echo "Excluded: $DIR" else echo "tar -cv $DIR | gzip -f9 > $DEST/`echo $DIR | awk -F '/' '{print \$1\$2}'`.tgz" # sleep 3 tar -cv $DIR | gzip -f9 > $DEST/`echo $DIR | awk -F '/' '{print \$1"-"\$2}'`.tgz fi done #tar -cv $DIR | gzip -f9 done for BIGDIR in $REALLYBIGFOLDERS do find $BIGDIR -maxdepth 1 -type d | while read DIR do if echo "$REALLYBIGFOLDERS" | grep "$DIR" > /dev/null; then echo "Excluded: $DIR" else echo "tar -cv $DIR | gzip -f9 > $DEST/`echo $DIR | awk -F '/' '{print \$1\$2\$3}'`.tgz" # sleep 3 tar -cv "$DIR" | gzip -f9 > $DEST/`echo $DIR | awk -F '/' '{print \$1"-"\$2"-"\$3}'`.tgz fi done find $BIGDIR -maxdepth 1 -type f -or -type l | grep -E "^.*\.a\$" > $DEST/bigfolders.tmp tar --files-from=$DEST/bigfolders.tmp -cv | gzip -f9 > $DEST/`echo $BIGDIR | awk -F '/' '{print \$1"-"\$2}'`-1-files-links-shared.tgz rm $DEST/bigfolders.tmp find $BIGDIR -maxdepth 1 -type f -or -type l | grep -v -E "^.*\.a\$" > $DEST/bigfolders.tmp tar --files-from=$DEST/bigfolders.tmp -cv | gzip -f9 > $DEST/`echo $BIGDIR | awk -F '/' '{print \$1"-"\$2}'`-1-files-links-static.tgz rm $DEST/bigfolders.tmp done