Listing 2.
#! /bin/bash
# A script to save certain meta-data off to
# the boot partition.
# Useful for restoration.
export zip="/mnt/zip";
export save="/mnt/save";
umount $zip
modprobe ppa
mount /dev/sda1
# clean it all out
rm -r $zip/*
mkdir $zip/lost+found
fdisk -l /dev/hda > $zip/fdisk.hda
ls -al /mnt > $zip/ls.mnt.txt
ls -al / > $zip/ls.root.txt
mkdir $zip/etc;
cp /etc/* $zip/etc
cd /
tar cf - boot | gzip -c > $zip/boot.tar.gz
tar cf - root | gzip -c > $zip/root.tar.gz
tar cf - etc | gzip -c > $zip/etc.tar.gz
tar cf - lib | gzip -c > $zip/lib.tar.gz
tar cf - usr/sbin | gzip -c > $zip/usr.sbin.tar.gz
tar cf - usr/bin | gzip -c > $zip/usr.bin.tar.gz
tar cf - sbin | gzip -c > $zip/sbin.tar.gz
tar cf - bin | gzip -c > $zip/bin.tar.gz
tar cf - dev | gzip -c > $zip/dev.tar.gz
# save the scripts we used to create the zip disk and
# the ones we will
# use to restore it.
mkdir $zip/root.bin
cp /root/bin/* $zip/root.bin
rm $zip/root.bin/*~ $zip/root.bin/#*#
# Not a normal part of the process: we duplicate the
# zip disk onto an
# NFS mount elsewhere.
rm -r $save/zip
mkdir $save/zip
cp -r $zip $save
df -m
Copyright © 1994 - 2018 Linux Journal. All rights reserved.