Wednesday, March 7, 2012

Automating SquirrelMail Backup on Ubuntu 9.04

If you are looking to automate SquirrelMail Backup on Ubuntu 9.04 or on any other flavor of Linux for that matter, read on...

Create a file called bak with the following contents and chmod 744 bak to make it executable.
rm  /backup/*.zip
rm -rf /backup/user_name
/usr/local/imap_tools/imapdump.pl  -f /backup/user_name -S localhost/user_name@your_domain/user_password
zip -r /backup/user_name_`date '+%d%m%Y'` /backup/user_name/.


The first line will delete any zipped files existing in the backup folder called backup in this case.

The second line will delete the backup of the IMAP folders that already exist from last time's backup. This is important since if the user had 20 emails in the last backup and he has thereafter deleted 5 emails that he does not require, the numbers get moved up and he will have 15 emails backed up numbering from 1 to 15 which will overwrite the emails numbered 1 to 15 from the previous backup. But the numbers 16 to 20 will still exist giving the user emails that he did not want and had deleted in case you want to restore SquirrelMail backup. Hence the deletion of the entire tree structure. The command rm -rf foldername removes the entire directory tree with all its files and subfolders and files.It is the Linux equivalent of deltree on DOS.

The third line backs up the IMAP folders of user user_name with password user_password on domain your_domain, storing it in folder /backup/user_name.

The fourth line zips the folder contents with subfolders and files creating a file with the username followed by date in DDMMYY format.

Learn how to copy a file from Linux to Windows here.

0 comments:

Post a Comment