Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

Evolution Mail backup.

# Filename:
# Version: 020112
# Author: robz
# This script creates an encrypted archive of all the relevant Evolution Mail
# directories and preferences to act as a backup to said program. Now I know
# Evo already provides a backup feature but AFAIK it isn't automateable and
# doesn't encrypt. You will need to modify your Evolution launcher/s path/s to
# point at this script instead of just "evolution"
# If you have sym/hard links to your Evolution directories "tar" will follow
# them, "find" however is not setup this way, you'll need the -L option if the
# path to your backup directory uses links. see "man find"
# You're required to have a personal gpg key setup, see "man gpg" or goto menu:
# System > Preferences > Encryption and Keyrings and create one for yourself.
# I would strongly suggest you do a manual Evolution generated backup before
# running this script, as insurance, what works for me bla bla bla :)

/usr/bin/evolution > /dev/null &                    # Start Evolution Mail.
EVO_PID=$!                                          # Get Evolution process ID.

until [ ! -e /proc/$EVO_PID ]; do sleep 2; done     # Loop till quit Evolution.

BUP_LOC="/media/Ext4Backup/Evo-backup"              # Where to save backup.
BUPNAME="evo-backup $(date +%H:%M" "%d%m%y).tar.gz" # Dated backup file name.

CRYPTTO="robz-public-key"                           # Your gpg public key name.

if [ ! -e "$BUP_LOC" ]; then                        # Do any backups exist?
    mkdir -p "$BUP_LOC"                             # Create save to directory.
# Create a README file with restore instructions, put it with the backups.
# The stuff between the angle brackets will need changing to your specifics.
# To restore this Evolution Mail backup, in a terminal do:

cd <The location of your encrypted backup file>
# The next line when executed will require your gpg NOT your login password.
gpg --decrypt --output "evo-backup" "evo-backup <relevent date>.gpg"
# Unzip the achive.
tar xzf evo-backup
# You will need to use Ctrl+H to make the files visible after unzipping.
evolution --force-shutdown
gconftool-2 --shutdown
# The next commands will overwrite existing configurations and files, be sure!
gconftool-2 --unload .evolution.xml
gconftool-2 --load .evolution.xml
cp -r .evolution .camel_certs "$HOME"
# Done.
# How are we now? -- Ready!

# Delete backups more than 5 days old.
find "$BUP_LOC" -name "evo-backup*" -mtime +5 -delete
# Trims to one backup a day, the newest. 
find "$BUP_LOC" -name "evo-backup*" -daystart -mtime -1 -delete

evolution --force-shutdown > /dev/null              # Kill Evo processes.
gconftool-2 --shutdown                              # Kill gconftool-2
gconftool-2 --dump /apps/evolution > .evolution.xml # Create preferences file.
# Create compressed encrypted archive.
tar -chz .evolution .camel_certs .evolution.xml -f "$BUP_LOC/$BUPNAME"
gpg --no-permission-warning --encrypt --recipient \
shred -zu "$BUP_LOC/$BUPNAME" .evolution.xml        # Clean up temp files.
/usr/lib/evolution/*/evolution-alarm-notify &       # Restart Evolution alarms.

No comments: