Hello

Excerpt from Bob Proulx:


-- <snip> --

>   # rsync -av /mnt/backup/etc/ /etc/
>   # rsync -n --delete -av /mnt/backup/etc/ /etc/
>   # rsync --delete -av /mnt/backup/etc/ /etc/

-- <snip> --

I believe this not to be a good idea. When you do this you mess around with
config files under the control of dpkg. With all the mess that creates.

I would reinstall everything you had/need again and then diff prior to mass
overwriting the files.

dirdif ()
{
    \diff -qrB --exclude='.hg' --exclude='.git' "${1%/}" "${2%/}"
}
[

'/var/lib/apt/extended_states' has the complete package list and knows which
packages are autoinstalled and which have been installed manually.

If you don't mind i attach my own '/etc/cron.daily/etckeeper' (it is only 4k)
which takes care for me to commit those important data into hg.
You can modify it to use your referred vcs instead.

It also compiles a list of installed packages into '/etc/apt/backup/'. Look at
the top of it.

Hope this is useful to you.

-- 
Regards,
Thilo

4096R/0xC70B1A8F
721B 1BA0 095C 1ABA 3FC6  7C18 89A4 A2A0 C70B 1A8F

#!/bin/bash
set -e

# enter debug mode:
# set -x

MY_APT_BACKUP_DIR=/etc/apt/backup

[ -d "${MY_APT_BACKUP_DIR}" ] || /bin/mkdir -p "${MY_APT_BACKUP_DIR}"

if [ -x /usr/bin/aptitude ]; then
      /usr/bin/aptitude -F '%p' search '~i~M' 
>"${MY_APT_BACKUP_DIR}"/packages_autoinstalled
  else
      printf "\naptitude not installed! # apt-get install aptitude\n\n"
      exit 11
fi

/usr/bin/dpkg --get-selections | \
    /usr/bin/awk '$2 == "install"' >"${MY_APT_BACKUP_DIR}"/packages_installed

if [ -x /usr/bin/debconf-get-selections ] ; then
     /usr/bin/debconf-get-selections >"${MY_APT_BACKUP_DIR}"/packages_debconf
  else
      printf "\ndebconf-get-selections not installed! # apt-get install 
debconf-utils\n\n"
      exit 12
fi



## etckeeper orig:
if [ -x /usr/bin/etckeeper -o -x /usr/sbin/etckeeper ] && [ -e 
/etc/etckeeper/etckeeper.conf ]; then
        . /etc/etckeeper/etckeeper.conf

        # are we configured?
        if [[ "${VCS}" != "hg" ]] ; then
            # etckeeper unconfigured! ...abort
            printf "\netckeeper unconfigured! edit 
/etc/etckeeper/etckeeper.conf first! \n\n"
            exit 13
        fi

        if [[ ! -x /usr/bin/hg ]]; then
            printf "\nmercurial not installed! # apt-get install mercurial \n\n"
            exit 14
        fi

        if [ "$AVOID_DAILY_AUTOCOMMITS" != "1" ]; then
                # avoid autocommit if an install run is in progress
                lockfile=/var/cache/etckeeper/packagelist.pre-install
                if [ -e "$pe" ] && [ -n "$(find "$lockfile" -mtime +1)" ]; then
                        rm -f "$lockfile" # stale
                fi
                if [ ! -e "$lockfile" ]; then
                        AVOID_SPECIAL_FILE_WARNING=1
                        export AVOID_SPECIAL_FILE_WARNING

                      # /etc
                        if [[ ! -d /etc/.hg ]]; then
                            etckeeper init -d /etc
                        fi
                        etckeeper pre-commit -d /etc >/dev/null 2>&1
                        etckeeper list-installed -d /etc 
>"${MY_APT_BACKUP_DIR}"/packagelist
                        if etckeeper unclean -d /etc ; then
                            etckeeper commit "$(hg status -R /etc/)" >/dev/null 
2>&1
                        fi


                      # /var/backups
                      if [[ -d /var/backups ]]; then
if [ ! -e /var/backups/.hgignore ]; then
    cat > /var/backups/.hgignore <<EOF
syntax: glob

*.gz

EOF
    chown root:root /var/backups/.hgignore
    chmod 0644 /var/backups/.hgignore
fi

                        if [[ ! -d /var/backups/.hg ]]; then
                            hg init /var/backups
                        fi
                        etckeeper pre-commit -d /var/backups/ >/dev/null 2>&1
                        if etckeeper unclean -d /var/backups/ ; then
                            etckeeper commit -d /var/backups/ "$(hg status -R 
/var/backups/)" >/dev/null 2>&1
                        fi
                      fi


                      # /var/lib/apt
                      if [[ -d /var/lib/apt ]]; then
if [ ! -e /var/lib/apt/.hgignore ]; then
    cat > /var/lib/apt/.hgignore <<EOF
syntax: glob

lists/*
mirrors/*
*~

EOF
    chown root:root /var/lib/apt/.hgignore
    chmod 0644 /var/lib/apt/.hgignore
fi

                        if [[ ! -d /var/lib/apt/.hg ]]; then
                            hg init /var/lib/apt
                        fi
                        etckeeper pre-commit -d /var/lib/apt/ >/dev/null 2>&1
                        if etckeeper unclean -d /var/lib/apt/ ; then
                            etckeeper commit -d /var/lib/apt/ "$(hg status -R 
/var/lib/apt/)" >/dev/null 2>&1
                        fi
                      fi


                      # /var/lib/aptitude
                      if [[ -d /var/lib/aptitude ]]; then
if [ ! -e /var/lib/aptitude/.hgignore ]; then
    cat > /var/lib/aptitude/.hgignore <<EOF
syntax: glob

*.old

EOF
    chown root:root /var/lib/aptitude/.hgignore
    chmod 0644 /var/lib/aptitude/.hgignore
fi
                        if [[ ! -d /var/lib/aptitude/.hg ]]; then
                            hg init /var/lib/aptitude
                        fi
                        etckeeper pre-commit -d /var/lib/aptitude/ >/dev/null 
2>&1
                        if etckeeper unclean -d /var/lib/aptitude/ ; then
                            etckeeper commit -d /var/lib/aptitude/ "$(hg status 
-R /var/lib/aptitude/)" >/dev/null 2>&1
                        fi
                      fi


                      # /var/lib/dpkg
                      if [[ -d /var/lib/dpkg ]]; then
                        if [[ ! -d /var/lib/dpkg/.hg ]]; then
                            hg init /var/lib/dpkg
                        fi
                        etckeeper pre-commit -d /var/lib/dpkg/ >/dev/null 2>&1
                        etckeeper list-installed >/var/lib/dpkg/packagelist
                        if etckeeper unclean -d /var/lib/dpkg/ ; then
                            etckeeper commit -d /var/lib/dpkg/ "$(hg status -R 
/var/lib/dpkg/)" >/dev/null 2>&1
                        fi
                      fi
                fi
        fi
fi

Reply via email to