Announcement

Collapse
No announcement yet.

howto - complete Kontact backup and restore

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    howto - complete Kontact backup and restore

    After some head scratching and serious brain damage from bashing my head against the wall here the solution to a problem that has haunted me for years (a kind soul on the KDE forum helped me out).

    Below are (graphical) scripts using kdialog to backup (post #2) and restore (post #3) all your Kontact settings.

    If you are at all unfamiliar with scripts here a little introduction:

    1. select the code with your mouse
    2. go to kate/vim/nano and press the middle mouse button to paste the selection
    3. save as kontact_backup.sh or kontact_restore.sh somewhere in your /home directory
    4. using the command line, go to the same path where you saved the scripts because you have to make the exectuable. To do so, type chmod +x name_of_script
    5. to execute a script on the command line, go to its path and type ./name_of_script

    Okay, now for scripts themselves...
    Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

    #2
    Re: howto - complete Kontact backup and restore

    Here the backup script:

    #/bin/sh
    # kdepim backup script with kdialog
    # v .2 2008-03-21
    #

    kdialog --dontagain pimbackup:helloworld --msgbox "This is a simple backup script for all data related to kdepim and kdenetwork like mails, contacts, settings et cetera. It will save all settings and data for the following apps: akregator, basket, kaddressbook, kgpg, kmail, knotes, kopete, korganizer and kwallet. Just choose the target folder "



    #
    # SETUP
    #

    StoreFLDR=$(kdialog --getexistingdirectory ~/ --title " Where shall i store the backup ? ")

    case $? in
    1) kdialog --sorry "Bye bye" ; exit ;;
    0) mkdir -p $StoreFLDR ; echo "ok" ;;
    esac

    TempFLDR=~/.pimbackup

    if [ -d "$TempFLDR" ] ; then
    rm -rf $TempFLDR
    mkdir $TempFLDR
    else
    mkdir $TempFLDR
    fi



    #
    # DATE FORMAT
    #
    # (YY.MM.DD - german)
    #Date=$(date +%d.%m.%g)
    # (DD-MM-YY)

    Date=$(date +%g-%m-%d)



    #
    # LETS START
    #
    dcopRef=`kdialog --title "pimBackup" --progressbar "Starting backup ..." 25`

    dcop $dcopRef setProgress 2
    dcop $dcopRef setLabel "Creating temporary folders ..."
    mkdir $TempFLDR/.kde
    mkdir $TempFLDR/.kde/share
    mkdir $TempFLDR/.kde/share/config
    mkdir $TempFLDR/.kde/share/apps
    mkdir $TempFLDR/.kde/share/config/kresources
    mkdir $TempFLDR/.gnupg

    dcop $dcopRef setProgress 3
    dcop $dcopRef setLabel "Copying email accounts ..."
    cp $HOME/.kde/share/config/emaildefaults $TempFLDR/.kde/share/config/

    dcop $dcopRef setProgress 4
    dcop $dcopRef setLabel "Copying email identities ..."
    cp $HOME/.kde/share/config/emailidentities $TempFLDR/.kde/share/config/

    dcop $dcopRef setProgress 5
    dcop $dcopRef setLabel "Copying kmail settings ..."
    cp $HOME/.kde/share/config/kmail.eventsrc $TempFLDR/.kde/share/config/
    cp $HOME/.kde/share/config/kmailrc $TempFLDR/.kde/share/config/

    dcop $dcopRef setProgress 6
    dcop $dcopRef setLabel "Copying kaddressbook settings ..."
    cp $HOME/.kde/share/config/kaddressbookrc $TempFLDR/.kde/share/config/
    cp -r $HOME/.kde/share/config/kresources/contact $TempFLDR/.kde/share/config/kresources/

    dcop $dcopRef setProgress 7
    dcop $dcopRef setLabel "Copying emails and account data ..."
    cp -r $HOME/.kde/share/apps/kmail $TempFLDR/.kde/share/apps/

    dcop $dcopRef setProgress 8
    dcop $dcopRef setLabel "Copying addressbook ..."
    cp -r $HOME/.kde/share/apps/kabc $TempFLDR/.kde/share/apps/

    dcop $dcopRef setProgress 9
    dcop $dcopRef setLabel "Copying Korganizer settings and entries ..."
    cp $HOME/.kde/share/config/korgacrc $TempFLDR/.kde/share/config/
    cp $HOME/.kde/share/config/korganizerrc $TempFLDR/.kde/share/config/
    cp -r $HOME/.kde/share/apps/korganizer $TempFLDR/.kde/share/apps/

    dcop $dcopRef setProgress 10
    dcop $dcopRef setLabel "Copying Kopete settings ..."
    cp $HOME/.kde/share/config/kopeterc $TempFLDR/.kde/share/config/
    cp $HOME/.kde/share/config/kopete $TempFLDR/.kde/share/config/
    cp $HOME/.kde/share/config/kopete.eventsrc $TempFLDR/.kde/share/config/
    cp -r $HOME/.kde/share/apps/kopete $TempFLDR/.kde/share/apps/
    cp -r $HOME/.kde/share/apps/kopete_otr $TempFLDR/.kde/share/apps/
    cp -r $HOME/.kde/share/apps/kopeterichtexteditpart $TempFLDR/.kde/share/apps/

    dcop $dcopRef setProgress 11
    dcop $dcopRef setLabel "Copying Konversation settings ..."
    cp $HOME/.kde/share/config/konversationrc $TempFLDR/.kde/share/config/
    cp $HOME/.kde/share/config/konversation.eventsrc $TempFLDR/.kde/share/config/
    cp -r $HOME/.kde/share/apps/konversation $TempFLDR/.kde/share/apps/

    dcop $dcopRef setProgress 12
    dcop $dcopRef setLabel "Copying Knotes settings and notes ..."
    cp $HOME/.kde/share/config/knotesrc $TempFLDR/.kde/share/config/
    cp -r $HOME/.kde/share/apps/knotes $TempFLDR/.kde/share/apps/

    dcop $dcopRef setProgress 13
    dcop $dcopRef setLabel "Copying GPG settings and keys ..."
    cp $HOME/.kde/share/config/kgpgrc $TempFLDR/.kde/share/config/
    cp -r $HOME/.gnupg/* $TempFLDR/.gnupg/

    dcop $dcopRef setProgress 13
    dcop $dcopRef setLabel "Copying Kwallet settings ..."
    cp -r $HOME/.kde/share/apps/kwallet $TempFLDR/.kde/share/apps/
    cp $HOME/.kde/share/config/kwalletrc $TempFLDR/.kde/share/config/

    dcop $dcopRef setProgress 14
    dcop $dcopRef setLabel "Copying Akregator settings ..."
    cp $HOME/.kde/share/config/akregator.eventsrc $TempFLDR/.kde/share/config/
    cp $HOME/.kde/share/config/akregatorrc $TempFLDR/.kde/share/config/
    cp $HOME/.kde/share/config/kopete.eventsrc $TempFLDR/.kde/share/config/

    dcop $dcopRef setProgress 15
    dcop $dcopRef setLabel "Copying Akregator feeds and cache ..."
    cp -r $HOME/.kde/share/apps/akregator $TempFLDR/.kde/share/apps/

    dcop $dcopRef setProgress 16
    dcop $dcopRef setLabel "Copying Basket settings ..."
    cp $HOME/.kde/share/config/basketrc $TempFLDR/.kde/share/config/

    dcop $dcopRef setProgress 17
    dcop $dcopRef setLabel "Copying Basket notes ..."
    cp -r $HOME/.kde/share/apps/basket $TempFLDR/.kde/share/apps/

    dcop $dcopRef setProgress 18
    dcop $dcopRef setLabel "Creating tarball ..."
    cd $TempFLDR
    sleep 1

    dcop $dcopRef setProgress 19
    dcop $dcopRef setLabel "Creating tarball ..."
    tar cf pimbackup.tar .

    dcop $dcopRef setProgress 20
    dcop $dcopRef setLabel "Checking bzip2 ..."

    if [ -e "/usr/bin/pbzip2" ] ; then
    dcop $dcopRef setProgress 21
    dcop $dcopRef setLabel "Nice, you have pbzip2 installed ..."
    sleep 2
    dcop $dcopRef setProgress 22
    dcop $dcopRef setLabel "Compressing tarball ..."
    pbzip2 -p2 -r pimbackup.tar
    else
    dcop $dcopRef setProgress 21
    dcop $dcopRef setLabel "Using standard bzip2 ..."
    sleep 2
    dcop $dcopRef setProgress 22
    dcop $dcopRef setLabel "Compressing tarball ..."
    bzip2 --best pimbackup.tar
    fi

    dcop $dcopRef setProgress 23
    dcop $dcopRef setLabel "Moving backup to destination ..."
    mv pimbackup.tar.bz2 $StoreFLDR/pimbackup.$Date.tar.bz2

    dcop $dcopRef setProgress 24
    dcop $dcopRef setLabel "Cleaning up ..."
    rm -rf $TempFLDR

    dcop $dcopRef setProgress 25
    dcop $dcopRef setLabel "Backup saved in $StoreFLDR"
    sleep 2
    dcop $dcopRef close

    kdialog --dontagain pimbackup:alldone --msgbox "You can find the compressed backup in $StoreFLDR, just extract it into your home directory to restore a backup or use the pimRestore script."

    exit 1
    Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

    Comment


      #3
      Re: howto - complete Kontact backup and restore

      And here the restore script:

      #/bin/sh
      #
      # KMail & Kontakte-Restore
      # Version 2006-05-31
      #

      kdialog --dontagain pimbackup:warning --msgbox "Please make sure the following apps are not running when restoring a backup: akregator, basket, kaddressbook, kgpg, kmail, knotes, kontact, kopete, korganizer and kwallet."

      #
      # SETUP
      #
      FILE=$(kdialog --getopenfilename ~/ --title "Choose your compressed backup")
      case $? in
      1) kdialog --sorry "Bye bye" ; exit ;;
      0) echo "ok" ;;
      esac

      TEMPFLDR=~/.pimbackup


      #-------------------------------------------------
      # START DES SCRIPTS
      #-------------------------------------------------

      ###
      ### Wiederherstellung starten
      ###

      ###
      ### DCOP Interface aktivieren
      ###
      dcopRef=`kdialog --title "Restoring backup" --progressbar "Starting restore" 6`

      ###
      ### Sicherung nach $HOME kopieren
      ###
      dcop $dcopRef setProgress 1
      dcop $dcopRef setLabel "Preparing ..."
      mkdir $TEMPFLDR
      cp -v $FILE $TEMPFLDR/pimbackup.tar.bz2

      ###
      ### Wechsle nach $HOME
      ###
      dcop $dcopRef setProgress 2
      dcop $dcopRef setLabel "Preparing ..."
      cd $TEMPFLDR

      ###
      ### Sicherung entpacken
      ###
      dcop $dcopRef setProgress 3
      dcop $dcopRef setLabel "Restoring backup ..."
      tar -xvvf pimbackup.tar.bz2

      dcop $dcopRef setProgress 4
      dcop $dcopRef setLabel "Restoring backup ..."
      cp -f -v -R .kde .gnupg $HOME

      ###
      ### Tempor�e Daten löschen
      ###
      dcop $dcopRef setProgress 5
      dcop $dcopRef setLabel "Cleaning up ..."
      rm -rf $TEMPFLDR

      ###
      ### Fertig / DCOP beenden
      ###
      dcop $dcopRef setProgress 6
      dcop $dcopRef setLabel "Done. Bye bye!"
      sleep 3
      dcop $dcopRef close
      exit 1
      Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

      Comment


        #4
        Re: howto - complete Kontact backup and restore

        This looks good. Thanks

        Comment


          #5
          Re: howto - complete Kontact backup and restore

          Re: Howto: Backup and restore your system!
          Backing up by AptonCD and restoring packages offline.

          First one have to install aptoncd in the offline computer or the computer which has no internet connection.

          The AptonCd can be downloaded with all dependecies in a folder of a internet computer and then can be installed in that internet computer and in any other computer which have no internet connection. To do this one has to be a superuser or administrator with password for the internet computer.

          the command is as follows

          root@ubuntu:/# apt-rdepends aptoncd 2>&1 | grep "^[a-zA-Z0-9_].*$" > /tmp/x1

          apt-rdepends to be installed first in the internet computer if not already installed.
          The above command is for creating a list for all dependencies for aptoncd with the main aptoncd package.

          Next commands are

          root@ubuntu:/# for f in `cat /tmp/x1` ; do apt-cache show $f | grep Filename | cut -f 2 -d ' ' ; done >/tmp/x2

          mkdir mycache
          [to keep the downloaded aptoncd package with all dependencies in the mycach folder under root]

          root@ubuntu:/# cd mycache

          root@ubuntu:/mycache# wget -B http://np.archive.ubuntu.com/ubuntu/ -i /tmp/x2

          [if wget is not already installed then it is to be installed first before executing the above command]
          this command will start downloading packages & all dependencies of aptoncd application.

          Now copy the mycache folder to the home directory of the computers which have no internet connection and install it in those computers.

          In the internet computer also install the aptoncd and make backup of all packages with upgrades and dependencies and make a CD/DVD/ISO image. Carry them to the computers having no internet connection and by using aptoncd application restore the packages and upgrades with all dependencies.

          So by using only one computer with internet one can install applications in other computers having no internet connection at all.

          Comment

          Working...
          X