#!/bin/bash
#-----------------------------------------------------------------------#
#                                                                       #
# Description : Backup an evolution profil                              #
# OS          : Linux                                                   #
# Requires    : evolution - tar                                         #
# Licence     : GPL                                                     #
# Version     : 0.1.0                                                   #
# Author      : Sebastien Bilbeau <sebastien.bilbeau@gmail.com>         #
# Web site    : http://www.tux-planet.fr/                               #
#                                                                       #
#-----------------------------------------------------------------------#

# Set script variable
USER=pti-seb
DATE=`date "+%F"`

# Go to user homedir
clear
cd /home/$USER

# Shutdown application
gconftool-2 --shutdown
evolution --force-shutdown

# Backup evolution setting
gconftool-2 --dump /apps/evolution > evolution_setting.xml

# Make a restore help file
/bin/cat > RESTORE_README.txt <<FINCONFIG
#!/bin/bash
# To restore your evolution profil, after extract this archive file,
# use the following command :

cd /home/$USER
gconftool-2 --shutdown
evolution --force-shutdown
tar jxvf bkp-evolution-$DATE.tar.bz2 
gconftool-2 --load evolution_setting.xml
rm -f evolution_setting.xml
FINCONFIG

# Compress and backup
tar cvfj bkp-evolution-$DATE.tar.bz2 --exclude=.evolution/mail/imap .evolution .gconf/apps/evolution .gnome2_private/Evolution .camel_certs evolution_setting.xml RESTORE_README.txt

# Remove tmp files
rm -f evolution_setting.xml
rm -f RESTORE_README.txt

# Change owner (for crontab use)
chown $USER:$USER bkp-evolution-$DATE.tar.bz2

# Display final backup message
echo "Evolution backup is finish !"
