Tuesday, December 19, 2017

Prechecks one-line script to take OS configuration file backup for manual patching in Linux

One-line script to collect Linux OS important configuration details:

Recently I had to patch my RHEL systems manually.
As a precautionary step, I had to take the backup of important system configuration files, just in case if system breaks, I could at least find the previous working OS configuration.

Below is the one-liner command that I used to collect the OS configuration.

# mkdir -p /var/OS_bak; cd /var/OS_bak; mkdir $(date +%F--%T); cd $(date +%F--%T); date > date.before ; hostname -f > hostname-f.before; cat /etc/redhat-release > redhat-release.before ; uname -r > uname-r.before ; sysctl -a > sysctl-a.before ;ifconfig -a > ifconfig.before ; netstat -tulpn > netstat-tulpn.before ; route -n > route-n.before ; iptables -n -v -L > iptables.before ; sestatus > sestatus.before ; ps -ef | awk -F " " '{print $8}' | sort | uniq > ps-ef.before ; chkconfig --list > chkconfig.before ; systemctl list-unit-files > systemctl-list-unit-files.before; env > env.before; fdisk -l > fdisk-l.before; pvs > pvs.before; vgs > vgs.before; lvs > lvs.before; mount > mount.before ; df -HT > df-HT.before ; cp /etc/fstab ./fstab.before ; cp /boot/grub*/grub.* ./ ; cp /etc/sysconfig/selinux ./selinux.before ; cd ; echo -en '\n'


1 comment:

  1. It's awesome in favor of me to have a web site, which is useful designed for my experience.
    thanks admin

    ReplyDelete