#* }
** Empty trash for users, ** Remove any cache/temporary files from areas that will be backed up ** Ensure the target directory exists ** Save crontabs for root and important users ** Save a list of manually installed packages ** Save the current lshw and inxi ** Save the current disk partitions, LVM data, ** Programmers might want to save lists of installed modules for their language
For example, a partial script to put all information to a place that will be backed up.
Code:
local_backup="/root/backups"
mkdir $local_backup
echo "INFO: Daily dump of important crontabs to $local_backup/"
$crontab -l -u root > $local_backup/crontab.root
if [[ 1 -eq $(/usr/bin/getent passwd jp | wc -l) ]] ; then
$crontab -l -u jp > $local_backup/crontab.jp
fi
if [[ 1 -eq $(/usr/bin/getent passwd www-data | wc -l) ]] ; then
$crontab -l -u www-data > $local_backup/crontab.www-data
fi
if [[ 1 -eq $(/usr/bin/getent passwd typo | wc -l) ]] ; then
$crontab -l -u typo > $local_backup/crontab.typo
fi
if [[ 1 -eq $(/usr/bin/getent passwd munin | wc -l) ]] ; then
$crontab -l -u munin > $local_backup/crontab.munin
fi
if [[ 1 -eq $(/usr/bin/getent passwd ubuntu | wc -l) ]] ; then
$crontab -l -u ubuntu > $local_backup/crontab.ubuntu
fi
if [[ 1 -eq $(/usr/bin/getent passwd zimbra | wc -l) ]] ; then
$crontab -l -u zimbra > $local_backup/crontab.zimbra
fi
$aptmark showmanual > $local_backup/apt-mark.manual
######[ to restore pkgs ]#######
### sudo apt-mark auto $ ( cat pkgs_auto.lst)
### sudo apt-mark manual $ ( cat pkgs_manual.lst)
### sudo apt-get -u dselect-upgrade
# Daily dump of current hardware to /root/backup
$lshw 2>&1 > $local_backup/lshw.list
$parted -lm > $local_backup/parted.txt
$df -Th -x squashfs -x tmpfs -x devtmpfs > $local_backup/df.txt
$pvs 2>&1 > $local_backup/pvs.txt
$vgs 2>&1 > $local_backup/vgs.txt
$lvs 2>&1 > $local_backup/lvs.txt
$blkid > $local_backup/blkid.txt
$lsblk -e 7 -o name,size,type,fstype,mountpoint > $local_backup/lsblk.txt
$inxi -Fxx > $local_backup/inxi.txt
if [[ -f $gem ]] ; then
$gem list --local > $local_backup/gem.list
fi
# Get list of installed perl modules, if any
if [[ -f $cpan ]] ; then
if [[ -d /usr/local/lib/site_perl || \
-d /usr/share/perl/*/App ]] ; then
$cpan -l > $local_backup/cpan.list
fi
fi
Last Update: 2023-02-09