Best way to backup up Linux configuration - Linux

This is a discussion on Best way to backup up Linux configuration - Linux ; Hi, I've put a lot of work into setting up sendmail/cyrus/DNS/DHCP etc. on my Linux box and I'd like to set up an automatic regular backup of all the configuration plus stuff like the contents of the cyrus mailboxes but ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Best way to backup up Linux configuration

  1. Best way to backup up Linux configuration

    Hi,

    I've put a lot of work into setting up sendmail/cyrus/DNS/DHCP etc. on
    my Linux box and I'd like to set up an automatic regular backup of all
    the configuration plus stuff like the contents of the cyrus mailboxes
    but I don't have the room to back up the entire system regularly.

    Is there a Linux tool that can help backup the information needed to
    return a virgin Linux installation to a configured setup (eg. if my disk
    crashed I could reinstall Mandrake 10.1 on a new disk and then restore
    my backup to retrieve all my settings).

    Any suggestions appreciated.

    Regards, Barry.

  2. Re: Best way to backup up Linux configuration

    On Fri, 15 Apr 2005 21:19:31 +0200, BarryNL wrote:
    > Hi,
    >
    > I've put a lot of work into setting up sendmail/cyrus/DNS/DHCP etc.


    Can we assume you kept a admin diary of what you changed where with what.
    Config file format can change from release to release.

    > on
    > my Linux box and I'd like to set up an automatic regular backup of all
    > the configuration plus stuff like the contents of the cyrus mailboxes
    > but I don't have the room to back up the entire system regularly.
    >
    > Is there a Linux tool that can help backup the information needed to
    > return a virgin Linux installation to a configured setup (eg. if my disk
    > crashed I could reinstall Mandrake 10.1 on a new disk and then restore
    > my backup to retrieve all my settings).
    >
    > Any suggestions appreciated.


    Hopefully the applications you use have documentation indicating where
    the config information resides.

    You can get your starter list with
    rpm -Va | grep '^..[5?]' > /tmp/starter.list
    after you login as root.


  3. Re: Best way to backup up Linux configuration

    Spake Bit Twister:
    > Hopefully the applications you use have documentation indicating where
    > the config information resides.
    >
    > You can get your starter list with
    > rpm -Va | grep '^..[5?]' > /tmp/starter.list
    > after you login as root.


    ....or if you're using a Debian system, policy requires that all config
    files reside in /etc and all database/spool type stuff reside in /var.

    --
    Trent Buck, Student Errant
    "Look, PHB, if you go for *NIX, you'll have to hire a *NIX admin, and
    they charge a bomb and dress like refugees. But with NT you just need
    someone with an MCSE."
    -- Omri Schwarz understands why the world is screwed.

  4. Re: Best way to backup up Linux configuration

    Trent Buck wrote:
    > ...or if you're using a Debian system, policy requires that all config
    > files reside in /etc and all database/spool type stuff reside in /var.
    >


    This is true for all FHS compliant distros. I use the following script
    (which can be used with cron) to backup /etc with tar. It should be
    easy enough to add all your emailboxes, db, and whatever else you wish
    to the script.

    You can then take the resulting tarball and scp it to another system
    for safe-keeping, copy it to tape, Flash drive, CD/DVD as your backup.

    Enjoy!

    -Wayne

    =============================cut-here==============================

    #!/bin/bash
    # Script to backup the /etc heirarchy
    #
    # Written 4/2002 by Wayne Pollock, Tampa Florida USA
    #
    # $Id: backup-etc,v 1.6 2004/08/25 01:42:26 wpollock Exp $
    #
    # $Log: backup-etc,v $
    # Revision 1.6 2004/08/25 01:42:26 wpollock
    # Changed backup name to include the hostname and 4 digit years.
    #
    # Revision 1.5 2004/01/07 18:07:33 wpollock
    # Fixed dots routine to count files first, then calculate files per dot.
    #
    # Revision 1.4 2003/04/03 08:10:12 wpollock
    # Changed how the version number is obtained, so the file
    # can be checked out normally.
    #
    # Revision 1.3 2003/04/03 08:01:25 wpollock
    # Added ultra-fancy dots function for verbose mode.
    #
    # Revision 1.2 2003/04/01 15:03:33 wpollock
    # Eliminated the use of find, and discovered that tar was working
    # as intended all along! (Each directory that find found was
    # recursively backed-up, so for example /etc, then /etc/mail,
    # caused /etc/mail/sendmail.mc to be backuped three times.)
    #
    # Revision 1.1 2003/03/23 18:57:29 wpollock
    # Modified by Wayne Pollock:
    #
    # Discovered not all files were being backed up, so
    # added "-print0 --force-local" to find and "--null -T -"
    # to tar (eliminating xargs), to fix the problem when filenames
    # contain metacharacters such as whitespace.
    # Although this now seems to work, the current version of tar
    # seems to have a bug causing it to backup every file two or
    # three times when using these options! This is still better
    # than not backing up some files at all.)
    #
    # Changed the logger level from "warning" to "error".
    #
    # Added '-v, --verbose' options to display dots every 60 files,
    # just to give feedback to a user.
    #
    # Added '-V, --version' and '-h, --help' options.
    #
    # Removed the lock file mechanism and backup file renaming
    # (from foo to foo.1), in favor of just including a time-stamp
    # of the form "yymmdd-hhmm" to the filename.
    #
    #

    PATH=/bin:/usr/bin

    # The backups should probably be stored in /var somplace:
    REPOSITORY=/tmp
    TIMESTAMP=$(date '+%Y%m%d-%H%M')
    HOSTNAME=$(hostname)
    FILE="$REPOSITORY/$HOSTNAME-etc-full-backup-$TIMESTAMP.tgz"

    ERRMSGS=/tmp/backup-etc.$$
    PROG=${0##*/}
    VERSION=$(echo $Revision: 1.6 $ |awk '{print$2}')
    VERBOSE=off

    usage()
    { echo "This script creates a full backup of /etc via tar in $REPOSITORY."
    echo "Usage: $PROG [OPTIONS]"
    echo ' Options:'
    echo ' -v, --verbose displays some feedback (dots) during backup'
    echo ' -h, --help displays this message'
    echo ' -V, --version display program version and author info'
    echo
    }

    dots()
    { MAX_DOTS=50
    NUM_FILES=`find /etc|wc -l`
    let 'FILES_PER_DOT = NUM_FILES / MAX_DOTS'
    bold=`tput smso`
    norm=`tput rmso`
    tput sc
    tput civis
    echo -n "$bold(00%)$norm"
    while read; do
    let "cnt = (cnt + 1) % FILES_PER_DOT"
    if [ "$cnt" -eq 0 ]
    then
    let '++num_dots'
    let 'percent = (100 * num_dots) / MAX_DOTS'
    [ "$percent" -gt "100" ] && percent=100
    tput rc
    printf "$bold(%02d%%)$norm" "$percent"
    tput smir
    echo -n "."
    tput rmir
    fi
    done
    tput cnorm
    echo
    }

    # Command line argument processing:
    while [ $# -gt 0 ]
    do
    case "$1" in
    -v|--verbose) VERBOSE=on; ;;
    -h|--help) usage; exit 0; ;;
    -V|--version) echo -n "$PROG version $VERSION "
    echo 'Written by Wayne Pollock '
    exit 0; ;;
    *) usage; exit 1; ;;
    esac
    shift
    done

    trap "rm -f $ERRMSGS" EXIT

    cd /etc

    # create backup, saving any error messages:
    if [ "$VERBOSE" != "on" ]
    then
    tar -cz --force-local -f $FILE . 2> $ERRMSGS
    else
    tar -czv --force-local -f $FILE . 2> $ERRMSGS | dots
    fi

    # Log any error messages produced:
    if [ -s "$ERRMSGS" ]
    then logger -p user.error -t $PROG "$(cat $ERRMSGS)"
    else logger -t $PROG "Completed full backup of /etc"
    fi

    exit 0

  5. Re: Best way to backup up Linux configuration

    BarryNL writes:

    >Hi,


    >I've put a lot of work into setting up sendmail/cyrus/DNS/DHCP etc. on
    >my Linux box and I'd like to set up an automatic regular backup of all
    >the configuration plus stuff like the contents of the cyrus mailboxes
    >but I don't have the room to back up the entire system regularly.


    (Almost) all config info is in /etc. So make sure you back that up.
    /var/spool contains some info.
    Then after that the badly written stuff could put its info anywhere.

    >Is there a Linux tool that can help backup the information needed to
    >return a virgin Linux installation to a configured setup (eg. if my disk
    >crashed I could reinstall Mandrake 10.1 on a new disk and then restore
    >my backup to retrieve all my settings).

    IF you have installed the same distro number, just copy the /etc directory
    over top of the default one and most things should work the same.



    >Any suggestions appreciated.


    >Regards, Barry.


  6. Re: Best way to backup up Linux configuration

    On Fri, 15 Apr 2005 21:19:31 +0200, BarryNL thoughtfully wrote:

    > Hi,
    >
    > I've put a lot of work into setting up sendmail/cyrus/DNS/DHCP etc. on my
    > Linux box and I'd like to set up an automatic regular backup of all the
    > configuration plus stuff like the contents of the cyrus mailboxes but I
    > don't have the room to back up the entire system regularly.
    >
    > Is there a Linux tool that can help backup the information needed to
    > return a virgin Linux installation to a configured setup (eg. if my disk
    > crashed I could reinstall Mandrake 10.1 on a new disk and then restore my
    > backup to retrieve all my settings).
    >
    > Any suggestions appreciated.
    >
    > Regards, Barry.




    Not perfect but how about :

    #!/bin/bash
    #
    # $Header: $
    # $Log: $

    declare d1=$(date +%m\/%d\/%Y)
    declare d2=$(date +%Y%m%d)
    declare HD=/home/noi

    echo "Starting conf archive process on $d1 " >> /tmp/archivestatus.txt

    cd $HD/archives
    #
    # find all conf, cnf, cf, RCS changed and significance files to backup
    # remove backup suffixes "~", ",v" etc.
    # Search /etc /boot /home and should probably do /usr

    find /boot/ /etc/ /home/ -iname "*.conf" -o -iname "*.old" \
    -o -iname "hosts*" -o -iname "*fstab*" -o -iname "*.cf" \
    -o -iname "*.cnf" -o -iname "*,v" -o -iname "crontabl*" \
    -o -iname "*iptables.*" -o -iname "*.ans" \
    | sed -e 's/~//' -e 's/,v//' -e '/.Trash/d' \
    | sort -dub > /tmp/tar_conf_files.txt

    tar -uf archiveconf.$d2.tar -T /tmp/tar_conf_files.txt
    mail -s "Archived conf+ $d1 files " noi@localhost < /tmp/tar_conf_files.txt

    # back up bash history

    cat $HD/archives/bash-history*.txt $HD/.bash_history >> /tmp/bash-history.txt \
    && rm $HD/archives/bash-history*.txt \
    && sed -f $HD/programs/sedscript /tmp/bash-history.txt > /tmp/bash-history2.txt \
    && sort -dub /tmp/bash-history2.txt > $HD/archives/bash-history-$d2.txt \
    && rm /tmp/bash-history*.txt
    cd $HD


    find $HD/archives -name "*.tar" -exec bzip2 -z {} \;

    # END

  7. Re: Best way to backup up Linux configuration

    Unruh wrote:

    > BarryNL writes:
    >
    >>Hi,

    >
    >>I've put a lot of work into setting up sendmail/cyrus/DNS/DHCP etc. on
    >>my Linux box and I'd like to set up an automatic regular backup of all
    >>the configuration plus stuff like the contents of the cyrus mailboxes
    >>but I don't have the room to back up the entire system regularly.

    >
    > (Almost) all config info is in /etc. So make sure you back that up.
    > /var/spool contains some info.
    > Then after that the badly written stuff could put its info anywhere.
    >
    >>Is there a Linux tool that can help backup the information needed to
    >>return a virgin Linux installation to a configured setup (eg. if my disk
    >>crashed I could reinstall Mandrake 10.1 on a new disk and then restore
    >>my backup to retrieve all my settings).

    > IF you have installed the same distro number, just copy the /etc directory
    > over top of the default one and most things should work the same.
    >
    >
    >
    >>Any suggestions appreciated.

    >
    >>Regards, Barry.



    So then all I wouldhave to do is burn the entire /etc and /home folders to a
    DVD and reload them over the same folders after I burn a new HD?

    This is the exact answer I have been looking for .. it sems almost too
    simple.

    All I want to do is keep my old settings and data when I clone another
    harddrive.

    Am I with you here or totally hosed?

    Cheers,

    Dave




    --
    Study History - Know the Future

    www.misterfixit.blogspot.com
    www.daves928.blogspot.com

+ Reply to Thread