Jay Mistry wrote:
I am new to Linux in general & have just started out with openSUSE 11.1 (dual boot with Windows XP Profnl.)
For Linux, what would be the critical system files that need to be backed-up (such as /etc/X11/xorg.conf, /boot/grub/menu.lst, etc/fstab, etc...) ?
On my home network, I daily backup /etc and /usr/local/etc completely. /var/{backups,named,pgk-get,sadm,spool,yp} /var/lib/{apt,mailman,mysql,pgsql,ldap,named,samba,rpm,zypp,nagios} /root /boot/grub partition infos list of installed rpms Of course, this is heavily influenced by the way that I use and configure my systems. You might want to look at the appended backup script and use ideas from it. (It won't run in your environment.) In my company, the answer is simple: We backup everything, no selection at all. HTH, Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod Email: jschrod@acm.org Roedermark, Germany #!/bin/bash # backup-sys 11 Nov 08 #------------------------------------------------------------ # Backup system configuration files, on Linux and Solaris. # Assumes NPC (uid-setup) environment. #set -x . /usr/local/etc/profile/cron-setup unset CDPATH export RSYNC_RSH=ssh sys="$1" shift case "$sys" in *puma) backup="pussy:/backup/$sys" ;; *pussy|*baghira) backup="puma:/backup/$sys" ;; *lion|*template|*ns|*www|*backend) backup=/data/sys-backup ;; *) echo "`basename $0` system [rsync_opts]" echo ' system is one of' echo ' *puma, *pussy, *baghira, *lion, *template, *ns, *www, *backend' exit 1 ;; esac # Determine rsync options rsync_protocol=`rsync --version | head -n 1 | sed 's/^.* //'` if [ "$SYS_OS" = 'linux2' -a "$rsync_protocol" -ge 29 -a "$HOSTNAME" != 'lion' ] then opt='-aHA --delete' else opt='-aH --delete' fi # /etc und /usr/local/etc komplett rsync $opt "$@" --exclude='/etc/sysevent' --exclude=repository_door /etc $backup error_code=$? if [ -d /usr/local/etc ] then case $backup in *:*) ( OIFS="$IFS" IFS=: set -- $backup IFS="$OIFS" ssh $1 mkdir -p $2/usr/local ) ;; *) mkdir -p $backup/usr/local ;; esac rsync $opt "$@" --exclude='/etc/sysevent' --exclude=repository_door \ /usr/local/etc $backup/usr/local error_code=`expr $error_code + $?` fi # other configs cd /var for i in backups named pkg-get sadm spool yp \ lib/apt lib/mailman lib/mysql lib/pgsql \ lib/ldap lib/named lib/samba lib/rpm lib/zypp \ lib/nagios do if [ -d $i ] then # Now we would like to ensure that the target directory # exists, but there is no easy way for that short of # parsing $backup and issuing ssh commands. Sigh. dir=`dirname $i` if [ "$dir" = '.' ] then dist=$backup/var else dist=$backup/var/$dir fi rsync $opt "$@" $i $dist error_code=`expr $error_code + $?` fi done # root home directory rsync $opt /root $backup error_code=`expr $error_code + $?` # Grub config, if it exists if [ -d /boot/grub ] then rsync $opt /boot/grub $backup error_code=`expr $error_code + $?` fi # System-Info on Linux case "$SYS_OS" in linux2) if [ -f /etc/SuSE-release ] then rm -f /var/tmp/rpm.lst rpm -q -a | sort >/var/tmp/rpm.lst && scp -q /var/tmp/rpm.lst $backup error_code=`expr $error_code + $?` rm /var/tmp/rpm.lst elif [ -f /etc/debian_version ] then rm -f /var/tmp/dpkg.lst dpkg -l >/var/tmp/dpkg.lst && scp -q /var/tmp/dpkg.lst $backup error_code=`expr $error_code + $?` rm /var/tmp/dpkg.lst fi # When we're on a vserver, there is no partitions list. if [ -f /proc/partitions ] then rm -f /var/tmp/fdisk.lst # fdisk -l doesn't work without errors on SUSE 9.2. It uses # /proc/partitions to get the device list where partitions should # be listed. This list includes md0 (the RAID-1 partition) and # a partition list is attempted to fetch from there. Therefore # we determine the list of devices ourselves: We take all IDE and # SCSI disks from /proc/partitions. fdisk -l `awk -v OFS= '$4 ~ /^[hs]d.$/ {print "/dev/",$4}' \ /proc/partitions` >/var/tmp/fdisk.lst && scp -q /var/tmp/fdisk.lst $backup error_code=`expr $error_code + $?` rm /var/tmp/fdisk.lst fi ;; sunos5) rm -f /var/tmp/fdisk.lst for i in `awk '/^\/dev\/dsk/ {print $1}' /etc/vfstab | sed 's/.$/2/' | sort -u` do prtvtoc $i done >/var/tmp/fdisk.lst && scp -q /var/tmp/fdisk.lst $backup error_code=`expr $error_code + $?` rm /var/tmp/fdisk.lst ;; esac # Are there Linux vservers? If yes, call backup-sys in each of them # that doesn't have a NO_BACKUP file in its root directory (one might # need to start it) and collect the resulting backups. # # FIXME: This only works with local $backup, as on lion. (Because of mkdir.) if [ -d /data/vservers ] then cd /data/vservers mkdir -p $backup/vservers/$vserver for vserver in * do test -d "$vserver" || continue test -d "$vserver/sbin" || continue test -f "$vserver/NO_BACKUP" && continue vserver $vserver running not_running=$? if [ "$not_running" = 1 ] then vserver $vserver start >/dev/null 2>&1 || continue fi cp -p $0 $vserver$0 vserver $vserver exec $0 $vserver test "$not_running" = 1 && vserver $vserver stop >/dev/null 2>&1 rsync $opt "$@" $vserver$backup/ $backup/vservers/$vserver done fi # On lion, we don't have /home/root/sicher/ to mark the backup # success. test -d /home/root/sicher && echo $error_code >/home/root/sicher/backup.$sys