Скалъпих едни скриптчета за backup. Имат нужда от доста преработка:
1) Да се добавят опции за home media директорийте.
2) Да се проверява за boot директорията
3) Да се добавят коментари
4) Тествано е, но трябва да се тества допълнително колкото може повече.
Наистина съжелявам, че няма да мога да дойда. След като оправих проблема със смените, се оказа че ще боядисвам...
Прилагам файлчетата ( не можах да ги прикача ;( ! Защо така
) :
backup.sh#First we check for root ID
if [ "$UID" -ne "0" ]; then
echo "You must be root to backup the system"
exit
fi
#the we determine if we should output help"
if [ "$1" = "help" ]; then
echo "Usage:"
echo " backup [dest-directory]"
echo "Back-ups root file system. "
echo "HINT: If no dest-direcotry presented - using default: /backup"
exit
fi
#which is the root folder
ROOT_DIRS=`ls /`
BACKUP_DEST_DIR="$1"
if [ ! -n "$1" ] ; then
echo "Setting back-up destenation to: /backup"
BACKUP_DEST_DIR="/backup"
fi
#whether or not to create the destenation directory
if [ ! -d "$BACKUP_DEST_DIR" ]; then
mkdir -p $BACKUP_DEST_DIR
echo "Destenation directory $BACKUP_DEST_DIR created!"
fi
BACKUP_DIRS=""
for dir in $ROOT_DIRS ; do
if [ "$dir" = "mnt" ] || [ "$dir" = "media" ] || [ "$dir" = "tmp" ] || [ "$dir" = "sys" ]; then
continue
fi
if [ "$dir" = "dev" ] || [ "$dir" = "proc" ] || [ "$dir" = "lost+found" ] || [ "$dir" = "home" ]; then
continue
fi
BACKUP_DIRS="$BACKUP_DIRS /$dir"
done
FILE_NAME="$BACKUP_DEST_DIR/backup-`date +%F`.tar.gz"
clear
echo "Directories to be backed up: $BACKUP_DIRS"
echo "Destenation: $FILE_NAME"
echo -n "Is that OK? [y/n]: "
read choice
if [ ! "$choice" = "Y" ] && [ ! "$choice" = "y" ]; then
echo "Aborting..."
exit
fi
if [ ! -f $FILE_NAME ]; then
echo "File with name: $FILE_NAME already exists."
echo -n "Shall it be overwritten? [y/n]: "
read choice
if [ "$choice" = "Y" ] || [ "$choice" = "y" ]; then
rm --interactive=none $FILE_NAME
echo "Old file removed"
sleep 1
else
exit
fi
fi
tar -czvf $BACKUP_DEST_DIR/backup-`date +%F`.tar.gz $BACKUP_DIRS
clear
echo "Operation successful!"
backup_restore.sh :
if [ "$UID" -ne "0" ]; then
echo "You must be root to use this script!"
echo "HINT: See 'su' and 'sudo' commands."
exit
fi
if [ ! -n "$1" ] || [ ! -n "$2" ]; then
echo "Restores backuped system..."
echo "Usage:"
echo " backup_restore mount_point arhive"
echo "Where 'mount_point' is the targeted root system"
echo " and 'archive' is the file source"
echo "---------------------------------------------------"
echo "HINT: Usually arhives are stored in /backup direcotory in the root file system"
echo "That means that you need to mount the drive and then find the arhive."
echo "Of course, that is not necessarary when backup direcotory specified"
exit
fi
MOUNT_POINT="$1"
ARCHIVE="$2"
if [ ! -f "$ARCHIVE" ]; then
echo "The file $ARCHIVE does not exist. Please, try again...
exit
fi
if [ ! -d "$MOUNT_POINT" ]; then
echo "$MOUNT_POINT is not valid destenation. Please, try again...
exit
fi
clear
echo "--------------------------------------------------"
echo "WARNING! All files in $MOUNT_POINT will be erased!"
echo "--------------------------------------------------"
echo -n "Is this OK? [y/n]: "
read choice
if [ ! "$choice" = "Y" ] && [ ! "$choice" = "y" ]; then
echo "Aborting..."
exit
fi
echo "Clearing directory entries..."
sleep 2
rm --interactive=none -R $MOUNT_POINT/*
ADD_FODLERS="media mnt lost+found sys proc tmp dev"
echo "Shall the following mount points and folders be created:"
echo "----------------------------------------"
echo "$ADD_FODLERS"
echo "----------------------------------------"
echo -n "[y/n]: "
read choice
if [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
for dir in $ADD_FODLERS; do
mkdir -p $MOUNT_POINT/$dir
done
fi
echo "Extracting archive $ARCHIVE"
sleep 1
tar -xzf $ARCHIVE -C $MOUNT_POINT
echo "Extraction successful!"
П.П Моля ви, наистина е хубаво след чиста и ПЪЛНА инсталация да се прави backup ( не изображение ). Някой да знае как да редактираме /boot/grub/menu.lst, че да се автоматизира процеса ?