参考程度になるかもしれませんので、当サイトでMaildirをバックアップするために使っているスクリプトを載せておきます。curとnewディレクトリだけを保存し、古いファイルを削除できます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/bin/sh # Remains at least these days keepday=14 HOMEDIR=/usr/local MAILDIR=$HOMEDIR/Maildir BACKUPDIR=$HOMEDIR/backup_mail FOLDERS="kuroneko-square.net" # Get timestamp timestamp=`date +%Y%m%d` old_date=`date "-d$keepday days ago" +%Y%m%d` cd $MAILDIR for F in $FOLDERS; do NAME=$BACKUPDIR/INBOX-$F-$timestamp.tar.gz FILES_CUR="`find $F -regex ".*cur.*"`" FILES_NEW="`find $F -regex ".*new.*"`" tar -cvzf $NAME $FILES_CUR $FILES_NEW rmfile=$BACKUPDIR/INBOX-$F-$old_date.tar.gz if [ -e $rmfile ]; then rm -f $rmfile fi done exit |