2 # this handler will save various reports of vital system information.
3 # by default, all the reports are enabled and are saved in /var/backups.
5 # (1) a list of all the packages installed and removed.
6 # this file can be used to restore the state of installed packages
7 # by running "dpkg --set-selections < dpkg-selections.txt
9 # (2) the partition table of all disks.
10 # this partition table can be used to format another disk of
11 # the same size. this can be handy if using software raid and
12 # you have a disk go bad. just replace the disk and partition it
13 # by running "sfdisk /dev/sdb < partitions.sdb.txt"
14 # (MAKE SURE YOU PARTITION THE CORRECT DISK!!!)
16 # (3) hardware information.
17 # write to a text file the important things which hwinfo can gleen.
21 getconf packagesfile /var/backups/dpkg-selections.txt
23 getconf partitions yes
24 getconf partitionsfile /var/backups/partitions.__star__.txt
27 getconf hardwarefile /var/backups/hardware.txt
29 if [ "$packages" == "yes" ]; then
30 if [ ! -x "`which dpkg`" ]; then
31 warning "can't find dpkg, skipping installed packages report."
36 if [ "$partitions" == "yes" ]; then
37 if [ ! -x "`which sfdisk`" ]; then
38 warning "can't find sfdisk, skipping partition report."
41 if [ ! -x "`which hwinfo`" ]; then
42 warning "can't find hwinfo, skipping partition report."
47 if [ "$hardware" == "yes" ]; then
48 if [ ! -x "`which hwinfo`" ]; then
49 warning "can't find hwinfo, skipping hardware report."
54 ## PACKAGES ##############################
57 # here we grab a list of the packages installed and removed.
60 if [ "$packages" == "yes" ]; then
61 dpkg --get-selections > $packagesfile
64 ## PARTITIONS #############################
66 # here we use sfdisk to dump a listing of all the partitions.
67 # these files can be used to directly partition a disk of the same size.
69 if [ "$partitions" == "yes" ]; then
70 devices=`hwinfo --disk | grep "Device File" | cut -d\ -f5`
71 for dev in $devices; do
72 [ -b $dev ] || continue
75 outputfile=${partitionsfile//__star__/$label}
76 debug "sfdisk -d $dev > $outputfile"
77 sfdisk -d $dev > $outputfile
81 ## HARDWARE #############################
84 # here we use hwinfo to dump a table listing all the
85 # information we can find on the hardware of this machine
88 if [ "$hardware" == "yes" ]; then
89 if [ -f $hardwarefile ]; then
93 echo -e "\n\n====================== summary ======================\n" >> $hardwarefile
94 debug "hwinfo --short --cpu --network --disk --pci >> $hardwarefile"
95 hwinfo --short --cpu --network --disk --pci >> $hardwarefile
96 for flag in cpu network disk bios pci; do
97 echo -e "\n\n====================== $flag ======================\n" >> $hardwarefile
98 hwinfo --$flag >> $hardwarefile