Freitag, 25. Januar 2008

HOWTO_ Backup your IMAP mail accounts

I just thought about what might happen if accidentally a crash or whatever will cause all my hundreds of personal E-Mail including logins, subscriptions, personal notes, etc to disappear? After years of fine service I prefer to have a backup of all this stuff. This is how I achieved it.

Backup user

First step is to create a user for the sole purpose of backing up files. You do not need it, however it is advised to use such one which has generally limited and some special permissions regarding reading passwords etc.
Go to the Control Panel, click User Accounts, and create a new account (I named it backup) with Limited permissions (that is it belongs solely to the group Users). One could add it to the group Backup Operators, however as I am not running any system backup, the limited rights of the Users group should be fine.
Remember to set a secure password of at least 10 characters, including capital and small letters, numbers and special characters (,:_+-).

Note: Perform the following steps as an Administrator unless advised otherwise!

Install IMAPSize

Using the freeware IMAPSize (version as of now is 0.3.6), your backup is just some clicks away. Download and install/unzip to a directory of your choice, presumably something like C:\Program Files\IMAPSize.
Change to that directory and create a new text file. Rename it to imapsize.log. Mark that file and the configuration imapsize.xml, right click, open Properties and change to tab Security. Now remove all users and groups from the list. Some permissions might be inherited, so you have to uncheck the Inherit option in the Advanced dialogue. Now add the backup user created in the first step, and additionally allow him to Modify and Write these two files.

Create backup directory

Now create a backup directory. It should be always accessible when performing backups (more on that later), so when using automation, only internal hard drives, internal mounted flash memory or an always-on file server comes to my mind. For security reasons the file system should allow you to set explicit permissions. I am using the local hard drive which is formatted with NTFS.
Let's say you choose D:\backup\mail. Create that directory, right click backup, open the Properties dialogue, switch to the Security tab, remove all users and groups from the list and add the backup user. Allow him Full control.

Setup IMAPSize

Start IMAPSize as the backup user. You can either login as that user or start IMAPSize in his context via StartMenu > Run.. using the following command:
runas /USER:backup "C:\Program Files\IMAPSize\imapsize.exe"
Cancel the dialogue for creating a new account. Open View > Options..., change to tab Misc and set the Root Backup Directory to the backup directory you created in the preceding step (e.g. D:\backup\mail).

Switch to tab Accounts and create one for each E-Mail account you want to backup. You can choose whatever name you want to, however using the full E-Mail address is the best choice for easy overview. Choose no spam handler and save your E-Mail password (check Save it). The passwords will be stored in plain text in the configuration file imapsize.xml, and that's why it is only accessible by the backup user!

Initial backup

To allow automatic and incremental backups, each account has to be manually backed up a first time. Perform the following steps for each account.
  1. Select the account from the drop down list in the upper left.
  2. Click Account backup (CTRL+B).
  3. Check all folders you want to back up.
  4. Press Save Folders to use that setting for future backups.
  5. Press Backup to start the process. You will be notified by a dialogue when completed.

Regular incremental backup

IMAPSize allows a simple command line usage. I wrote the following batch script for automation and placed it as autobackup.cmd in the IMAPSize program folder. Remove all permissions and add the user backup as stated above.
:: IMAPSize account names to backup

ECHO Starting IMAP account backup...
FOR /F "usebackq delims== tokens=2" %%A IN (`SET IMAP_ACCOUNT_NAME_`) DO (
ECHO * Backing up account %%A...
"%~dp0imapsize.exe" -backup -account=%%A
ECHO Backup finished.
ECHO Full backup log available in file %~dp0imapsize.log.
Open the task scheduler to setup a regular backup. Open it via Start > Programs > Accessories > System Tools > Scheduled Tasks. Double click Add Scheduled Task, click Next, Browse to the script file autobackup.cmd and select it. Now you can select a name like "Daily IMAP backup" and check Daily. Click Next and choose a time (should be a time when you your PC is online nearly every day). Click Next and set backup as the user. Type in twice the according password. Click Next and then Finish.

Increase security

To increase security, you also have to change to owner of the files you changed the permissions of. First, you have to add the backup user to the Administrators group. Open User Accounts in the Control Panel, click Change an account, select the user backup, click change the account type, and switch it to Computer Administrator.
Now log in with backup, browse to the program directory of IMAPSize, select the files imapsize.xml, imapsize.log and autobackup.cmd, right click and open Properties, change to Security tab, click the Advanced button, change to the Owner tab, select the backup user and apply changes.
Do the same with the backup folder, but additionally check Replace owner on subcontainers and objects.

Logout and login with administrator, and switch the backup user back to the Limited account. Now you're done!


Informationstechnische Howtos, Hinweise und Merkwürdiges

Batchlib v1.0 2008-03-29

Aktuelle Beiträge

HOWTO_ O2 DSL Surf &...
Der O2 DSL Surf & Phone-Router ist für die...
cypressor - 12. Feb, 19:57
Uptweak Windows XP Home...
There are a lot of annoying limitations in Windows...
cypressor - 9. Okt, 19:30
BATCHLIB_ Batchlib package...
Download Batchlib package v1.0 (5 KB zip file) What...
cypressor - 29. Mrz, 19:10
BATCHLIB_ Batchlib library...
The batchlib library string.cmd is part of the batchlib...
cypressor - 29. Mrz, 18:10

Homepage Ticker



Online seit 4471 Tagen
Zuletzt aktualisiert: 28. Jun, 11:32
RSS XML 1.0 Button-Get-Firefox

Weblog abonnieren