ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Michael Shigorin <mike@lic145.kiev.ua>
To: mandrake-russian@altlinux.ru
Subject: [mdk-re] mailrotate.sh (а также к слову о быстрой настройке почты)
Date: Tue Oct 23 09:51:04 2001
Message-ID: <20011023083831.E2319@lic145.kiev.ua> (raw)
In-Reply-To: <20011023091528.722bc4f5.a_prokudin@pub.tmb.ru>


[-- Attachment #1.1: Type: text/plain, Size: 897 bytes --]

On Tue, Oct 23, 2001 at 09:15:28AM +0400, Alexandre Prokoudine wrote:
> А кстати, каким образом можно автоматизировать бэкапинг почты? Ну, так,
> Какие идеи будут?
Стоп. Или я на днях постил mailrotate.sh, или скажите, что я
неправ. Цепляю еще раз.

Кстати, вообще есть мысль наваять тиклевый конфигуратор
(quickstarter этакий) на тему "сделать ~/.procmailrc (с фильтром
дубликатов :-d), запустить fetchmailconf, включить бэкап,
прописать его в кронтаб; взять базовые настройки почтовки из
/etc/skel || набора".

Пока чуть-чуть застрял с интерфейсом (в общем виде). Хотя, по
правде, сделать бы это все модульным и умным, не стыдно было бы и
в мир показать. Пока даже приаттачить считай что нечего :(

-- 
WBR, Michael Shigorin -- webmaster at www.chem.univ.kiev.ua
>Home Page:  http://visa.chem.univ.kiev.ua/~mike/  ICQ: 113344029
>Brainbench: http://www.brainbench.com/transcript.jsp?pid=2434729

[-- Attachment #1.2: mailrotate.sh --]
[-- Type: text/plain, Size: 1918 bytes --]

#!/bin/sh
# A free script to rotate mail by Michael Shigorin <mike@altlinux.ru>
# v20011020

# moves $MBOXES (wildcards allowed) in $MAIL to files named after $DATEFMT in
# directories under $ARCROOT, leaving fresher than $KEEP (see also $SINCEAFTER)
# not to leave mailboxes empty.

# WARNING: BACKUP YOUR MAIL BEFORE USING! NO WARRANTIES!

MDIR="$HOME/mail"
ARCROOT="$MDIR/archive"
MBOXES="_* READ MDS"
LOG="$ARCROOT/mailrotate.log"
KEEP="7 days"	# to leave me in context
KEEPEMPTY=	# keep empty boxes? "" or non-empty string
SKIPEXIST=	# skip existing archive mbox or append to it?
MODE=644	# mktemp will 
DATEFMT="%Y-%m-%d"
SINCEAFTER=after	# ...or "since". One day difference.
MAILPS="mutt"	# egrep's regexp, i.e. (mutt|pine|sylpheed)

echo `date +$DATEFMT` >>$LOG
[ -n "`ps -u $USER | egrep " $MAILPS$"`" ] && {
	echo "$MAILPS running as $USER, exiting..." >>$LOG
	exit
} || echo "$0: starting..." >>$LOG

perl -e 'require Date::Parse; require Date::Manip' || {
	echo "ERROR: grepmail needs Date::Parse and Date::Manip to" >&2
	echo "       enable -d option (which we need)." >&2
	echo >&2
	echo "Exiting to keep your mail safe; please run" >&2
	echo "perl -MCPAN -e 'install Date::Parse' && perl -MCPAN -e 'install Date::Manip'" >&2
	echo "as root to install the needed modules!" >&2
	exit 1
}

cd "$MDIR"
for i in $MBOXES; do
	[ ! -f "$i" -o -f "$i.lock" ] && continue
	ARCDIR="$ARCROOT/$i"
	[ -d "$ARCDIR" ] || mkdir -p "$ARCDIR"
	ARCMBOX="$ARCDIR/`date -d "$KEEP ago" +$DATEFMT`"
	[ -f "$ARCMBOX" -a "$SKIPEXIST" ] && continue
	TMPFILE="`mktemp "$i.tmp-XXXXXX"`"
	grepmail -had "$SINCEAFTER $KEEP ago" "$i" >"$TMPFILE" 2>>$LOG
#	[ -f "$ARCMBOX" ] && echo "WARNING: $ARCMBOX already exists!" >>$LOG
	grepmail -vhad "$SINCEAFTER $KEEP ago" "$i" >>"$ARCMBOX" 2>>$LOG
	[ -s "$TMPFILE" -o "$KEEPEMPTY" ] && {
		mv "$TMPFILE" "$i"
		chmod $MODE "$i"
	}
	[ -s "$ARCMBOX" -o "$KEEPEMPTY" ] || rm -f "$ARCMBOX"
done


[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

  parent reply	other threads:[~2001-10-23  9:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-23  7:23 [mdk-re] procmail, postfix and very big mbox Alexey Voinov
2001-10-23  9:12 ` Alexandre Prokoudine
2001-10-23  9:33   ` Oleg S. Gints
2001-10-23 10:33     ` Michael Shigorin
2001-10-23  9:51   ` Michael Shigorin [this message]
2001-10-23 10:15     ` [mdk-re] mailrotate.sh (а также к слову о быстрой настройке почты) Alexandre Prokoudine
2001-10-23 10:42       ` Michael Shigorin
2001-10-24 14:10 ` [mdk-re] procmail, postfix and very big mbox Dmitry V. Levin
2001-10-24 19:40   ` Michael Shigorin
2001-10-25  7:22   ` Alexey Voinov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011023083831.E2319@lic145.kiev.ua \
    --to=mike@lic145.kiev.ua \
    --cc=mandrake-russian@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git