Posts Tagged ‘crontab’
Getting SpamAssasin to Learn from Emails in mailbox folder
I use this command to learn from spam in a folder on a virtual mail box.
sa-learn –spam /var/spool/postfix/virtual/DomainName.com/emailaddress/.Possible_Spam/cur/* –showdots
This then runs on a Cron Tab each day. Care must be taken that no non-spam messages are added to this folder, so only use this with users you trust.
I am working on a way that it will iterate through each mail box and find the possible_spam folders on all virtual boxes and learn from them all at once.
I also want to get postfix/courier to automatically create the possible_spam folders on all new mail boxes.
Backing Up MySQL Databases on a CRON
With all the websites that I run, keeping backups is essentail.
I first wrote a bash script that I ran on a cron job whcih backed up each database and then zipped the sql file up:
#!/bin/sh
mysqldump -uroot -ppwd --opt db1 > /sqldata/db1.sql
mysqldump -uroot -ppwd --opt db2 > /sqldata/db2.sql
cd /sqldata/
tar -zcvf sqldata.tgz *.sql
This meant that I had to modify this backup script each time I added a database. I then found that you can use the ‘–all-databases’ option to backup all the databases at once:
#!/bin/sh–all-databases
mysqldump -uroot -ppwd > /sqldata/data.sql
cd /sqldata/
tar -zcvf sqldata.tgz *.sql
This works perfectly.
After creating the Tar file I store it on the server where a secondary script runs copying thes backups off site and deleting fiels older than 21 days, meanind that I have a rolling 3 week backup both on the server and off the server.