[opensuse] Re: Important system files/folders to back-up
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
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
I don't use any database/server apps (also not familiar with those); as mentioned this is just a stand-alone home PC for general (documents, Internet, etc + to learn Linux) use; so minus those, would probably backup the other dirs. Basically, was not sure of the main directories (folders) to be backed up on a Linux system. Also, /home (all) and /etc (all). This, I do from a bootable 'live CD' (I personally prefer the 'Parted Magic 3.5 CD), rather than login as 'root' into a working system.
partition infos list of installed rpms
How does one backup those (esp. 'partition infos' ) ? (I believe the list of installed RPM's can be backed up as an .xml file (from YaST --. Software Management) ?
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
Even with modifications, I am not an advanced Linux user to be able to configure and run scripts...just begun using Linux about 3 months back & and also not a computer professional. This is a dual-boot system with Windows XP (earlier OS) also installed & I switch b/w Windows & openSUSE 11.1. I backup the Windows partition (C;/) using a Norton Ghost 2003 bootable CD. However, I cannot use this for Linux as NG 2003 will not see Linux file systems (all Linux partns are .ext3). So, I used the "partimage" program from the above 'Parted Magic' CD to backup / (root) and /home partitions to another partition on the same hard disk. This is the first time I have used 'partimage', so even though partition images were created successfully, I am not sure if they will be able to be restored successfully. Thanks for the advice though, Jay == -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (2)
-
Jay Mistry
-
Joachim Schrod