1

Topic: How can I delete or arhive mail older than X months ?

==== Provide basic information to help troubleshoot ====
- iRedMail version: 0.7.3
- Linux/BSD distribution name and version: Ubuntu 10.10
- iRedAdmin-Pro for Mysql 1.3.0
====

Hi!
My question is simple - How can I delete or arhive mail older than X months, for example, for the 1 user ? for the entire domain ?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: How can I delete or arhive mail older than X months ?

Since each mail message is a single file, you can try to search files which were CREATED older than X days/months/years with command "find".

For example:

# Find files older than 7 days.
find /var/vmail/vmail1 -ctime +7

# DELETE files older than 7 days, and print the name of each file it deletes.
find /var/vmail/vmail1 -ctime +7 -exec rm -f {} \;

For more detail, please refer to manual page of command "find".

3 (edited by Leonid 2011-11-08 03:09:05)

Re: How can I delete or arhive mail older than X months ?

Thank you for your reply.

If I understood correctly:
- To delete messages older than x days, is sufficient to remove the files of email?
- To archiving - enough to find files older than x days and archive them?

With mysql nothing else to do?

(one more thing. as i see in manual, preferably using mtime than ctime, and if we don't need the names of deleted files, than we can use -delete parameter, coz it's run faster than exec rm, i.e. find /var/vmail/vmail1 -type f -mtime +7 -delete)

4

Re: How can I delete or arhive mail older than X months ?

Leonid wrote:

- To delete messages older than x days, is sufficient to remove the files of email?

You're right.

Leonid wrote:

- To archiving - enough to find files older than x days and archive them?

Correct.

Leonid wrote:

With mysql nothing else to do?

There's no mail message related info stored in MySQL.

Leonid wrote:

(one more thing. as i see in manual, preferably using mtime than ctime, and if we don't need the names of deleted files, than we can use -delete parameter, coz it's run faster than exec rm, i.e. find /var/vmail/vmail1 -type f -mtime +7 -delete)

It's up to you.
Ctime means "Created" time, mtime means "Last Modified" time, atime means "Last Access" time.

P.S. Would you mind sharing with us your idea/solution of archiving old mails? Just using 'find' and then moving them to archive folder?

5 (edited by Leonid 2011-11-09 13:06:04)

Re: How can I delete or arhive mail older than X months ?

ZhangHuangbin wrote:
Leonid wrote:

(one more thing. as i see in manual, preferably using mtime than ctime, and if we don't need the names of deleted files, than we can use -delete parameter, coz it's run faster than exec rm, i.e. find /var/vmail/vmail1 -type f -mtime +7 -delete)

It's up to you.
Ctime means "Created" time, mtime means "Last Modified" time, atime means "Last Access" time.

not quite right. as in manual:
- ctime = "File's status was last changed n*24 hours ago." It means time of changes in file or attributes of file;
- mtime = "File's data was last modified n*24 hours ago." It means last mofified time;

both of these parameters are largely the same, but there are differences. For example, the command to rename or move a file (mv), and chmod, and chown - change the value of ctime, but do not change mtime... and so on... So, for my purposes preferably use mtime. smile

i think that you expect a crtime - creation time, but this parameter was born starting with ext4 file system and not all have this (unlike mtime).

ZhangHuangbin wrote:

P.S. Would you mind sharing with us your idea/solution of archiving old mails? Just using 'find' and then moving them to archive folder?

I will share with you working way to backup email when thoroughly test it.

ty for you products and we are waiting iRedOS for ubuntu smile

6

Re: How can I delete or arhive mail older than X months ?

Leonid wrote:

- ctime = "File's status was last changed n*24 hours ago." It means time of changes in file or attributes of file;

Thanks very much for correcting me. smile

7

Re: How can I delete or arhive mail older than X months ?

ZhangHuangbin, tell me please, in mail directories i see many files with dovecot* in names (dovecot.index, dovecot.index.cache, maildifolders, subscriptions and so on). What is that ? Can I safely delete these files if they are older than I need?  i think not so simple...

8

Re: How can I delete or arhive mail older than X months ?

Leonid wrote:

in mail directories i see many files with dovecot* in names (dovecot.index, dovecot.index.cache, maildifolders, subscriptions and so on). What is that ? Can I safely delete these files if they are older than I need?  i think not so simple...

These files are created and used by IMAP server, Dovecot.
If you delete them, Dovecot will create them automatically, but it's not recommended. So please don't touch them.

9

Re: How can I delete or arhive mail older than X months ?

While deleting the emails in vmail seems to get rid of the emails, i still seem to hit the mail box limit. Even though there are no emails in the round cube client, the little graphic next to the settings says that im at 100% limit for my mailbox. Do i have to reset the maildir size anywhere after i delete the emails from vmail?

Thanks,

10

Re: How can I delete or arhive mail older than X months ?

Hi anvesh,

You need to delete record for this user in SQL table "vmail.used_quota".

Please create a new forum topic for your own question next time, do not hijack other's thread.