my-scripts/SavePC.sh

63 lines
2.4 KiB
Bash
Raw Normal View History

#!/bin/sh
2021-11-01 21:49:18 +00:00
# Save some data on a mounted filesystem
#
2021-11-01 21:49:18 +00:00
# (c) LUG-VS (GPL)
VERSION="$(basename $0) Version 1.0.0 from 2021-11-01"
##
# Requires root rights!
# Input: -v for verbose
# Output: saved data
##
# 1.0.0
# branch for sharing
## Define destination (e.g. NFS or DavFS mounted remote NAS or trusted Server)
MyDest="/mnt/remote"
## Check if Destination exists
if [ ! -d ${MyDest} ] ; then
echo "*** Error: No Destination found"
exit 10
fi
2021-11-01 21:49:18 +00:00
## Generate dedicated subdirectory for each host PC
if [ -d ${MyDest}/$(hostname) ] ; then
MyDest=${MyDest}/$(hostname)
fi
2021-11-01 21:49:18 +00:00
## Short message (in this case in German) showing the what was done
if [ "$1"="-v" ] ; then
echo "Sichere /etc und /root sowie SmartCtl in Ziel <${MyDest}>"
fi
2021-11-01 21:49:18 +00:00
## Save main settings and personal data of root
tar -cvzf ${MyDest}/$(hostname)_$(date +%F)_etc.tgz /etc /usr/etc
tar -cvz --exclude=/root/.duc.db -f ${MyDest}//$(hostname)_$(date +%F)_root.tgz /root
[ -d /var/lib/named/ ] && tgz ${MyDest}/$(hostname)_$(date +%F)_named.tgz /var/lib/named/
[ -d /var/yp/ ] && tgz ${MyDest}/$(hostname)_$(date +%F)_yp.tgz /var/yp/
[ -d /usr/lib/ypbind/ ] && tgz ${MyDest}/$(hostname)_$(date +%F)_ypbind.tgz /usr/lib/ypbind/
2021-11-01 21:49:18 +00:00
## Some other informations like HW interfaces and disks
which lsusb &> /dev/null && lsusb &> ${MyDest}/lsusb_$(date +%F).txt
which lspci &> /dev/null && lspci &> ${MyDest}/lspcci_$(date +%F).txt
which fdisk &> /dev/null && fdisk -l &>> ${MyDest}/fdisk-l_$(date +%F).txt
which lsblk &> /dev/null && lsblk &>> ${MyDest}/lsblk_$(date +%F).txt
2021-11-01 21:49:18 +00:00
## If sensors then save sensor informations like temperature and voltages
which sensors &> /dev/null && sensors &> ${MyDest}/sensors_$(date +%F).txt
which sensors &> /dev/null && sensors -u &>> ${MyDest}/sensors-u_$(date +%F).txt
2021-11-01 21:49:18 +00:00
## If inxi is installed then save this info
which inxi &> /dev/null && inxi -Fxd &>> ${MyDest}/inxi-Fxd_$(date +%F).txt ## disabled da inxi sich in scripten aufhängt
## If mdadm is installed and /proc/mdstat exists than save raid infos
which mdadm &> /dev/null && for dev in $( mdadm -Ebsc=partitions | cut -d' ' -f2 ) ; do mdadm -D $dev &>> ${MyDest}/mdadm-D_$(date +%F).txt ; done
[ -f /proc/mdstat ] && cp /proc/mdstat ${MyDest}/mdstat_$(date +%F).txt
## Store some HW-Info
# if hwinfo (e.g. at openSUSE) existis
which hwinfo &> /dev/null && hwinfo &> ${MyDest}/hwinfo_$(date +%F).txt
which hwinfo &> /dev/null && hwinfo --short &> ${MyDest}/hwinfo-short_$(date +%F).txt