postfix queue file write error message size limit

If you get an error like:
Aug 21 12:41:03 webb4 postfix/sendmail[11234]: fatal: web1_user(12967): queue file write error

in your mail log, then the vale for message_size_limit in postfix main.cf is too low. Edit postfix main.cf:

vi /etc/postfix/main.cf
and set the message size limit to a higher value. E.g.
message_size_limit = 900000000
and restart postfix:

/etc/init.d/postfix restart

If there is no message_size_limit set in main.cf, just add the line.

The configuration option is "message_size_limit" and by default is set to 10240000 bytes which is roughly 10MB. You can see what setting your postfix install is currently using by issuing the following command:

postconf | grep message_size_limit

Just doing "postconf" on its own will show all the options so using grep on "message_size_limit" filters the output to just the setting we want. For the default setting, you'll see this:
message_size_limit = 10240000
To change the setting to some other value, open the main.cf file in your favourite text editor (it's often at a location like /etc/postfix/main.cf) and either edit or add the following line, depending if it's already in the file or not.
message_size_limit = 20480000
In the above example I've changed it to ~20MB.
Then reload postfix like so:
service postfix reload

Recommended:
postconf | grep message_size_limit
postconf -e message_size_limit=20480000             
service postfix reload

Something to note: many emails use base64 (there is 8bitmime but support is far from universal). So the space taken up by the attatchment in the email will be about a third bigger than the total size of the attatchments. Then you have to consider the rest of the mail.
So if you want to receive 20MB files you need to set the message size limit to around 27MB.


lsof command

Who are browsing my home/office web server?
lsof -r 2 -n -P -c nginx -a -i TCP@IPAddress:80

Feel free to replace port 80 with other ports such as 21 (FTP), 22(SSH), 443 (HTTPS) and so on to get the same info. The -c options set the user name (see man page http://www.manpager.com/linux/man8/lsof.8.html for more info on all options) :
lsof -r 2 -n -P -c vsftpd -a -i TCP@IPAddress:21
lsof -r 2 -n -P -c sshd -a -i TCP@IPAddress:22


netstat -punt | grep ":80"

http://www.manpager.com/linux/man8/lsof.8.html

8 Linux TR Command Examples

tr is an UNIX utility for translating, or deleting, or squeezing repeated characters. It will read from STDIN and write to STDOUT.
tr stands for translate.

Syntax

The syntax of tr command is:
$ tr [OPTION] SET1 [SET2]

Translation

If both the SET1 and SET2 are specified and ‘-d’ OPTION is not specified, then tr command will replace each characters in SET1 with each character in same position in SET2.

1. Convert lower case to upper case

The following tr command is used to convert the lower case to upper case
$ tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
thegeekstuff
THEGEEKSTUFF
The following command will also convert lower case to upper case
$ tr [:lower:] [:upper:]
thegeekstuff
THEGEEKSTUFF
You can also use ranges in tr. The following command uses ranges to convert lower to upper case.
$ tr a-z A-Z
thegeekstuff
THEGEEKSTUFF

2. Translate braces into parenthesis

You can also translate from and to a file. In this example we will translate braces in a file with parenthesis.
$ tr '{}' '()' < inputfile > outputfile
The above command will read each character from “inputfile”, translate if it is a brace, and write the output in “outputfile”.

3. Translate white-space to tabs

The following command will translate all the white-space to tabs
$ echo "This is for testing" | tr [:space:] '\t'
This is for testing

4. Squeeze repetition of characters using -s

In Example 3, we see how to translate space with tabs. But if there are two are more spaces present continuously, then the previous command will translate each spaces to a tab as follows.
$ echo "This   is   for testing" | tr [:space:] '\t'
This   is   for testing
We can use -s option to squeeze the repetition of characters.
$ echo "This   is   for testing" | tr -s [:space:] '\t'
This is for testing
Similarly you can convert multiple continuous spaces with a single space
$ echo "This  is  for testing" | tr -s [:space:] ' '
This is for testing

5. Delete specified characters using -d option

tr can also be used to remove particular characters using -d option.
$ echo "the geek stuff" | tr -d 't'
he geek suff
To remove all the digits from the string, use
$ echo "my username is 432234" | tr -d [:digit:]
my username is
Also, if you like to delete lines from file, you can use sed d command.

6. Complement the sets using -c option

You can complement the SET1 using -c option. For example, to remove all characters except digits, you can use the following.
$ echo "my username is 432234" | tr -cd [:digit:]
432234

7. Remove all non-printable character from a file

The following command can be used to remove all non-printable characters from a file.
$ tr -cd [:print:] < file.txt

8. Join all the lines in a file into a single line

The below command will translate all newlines into spaces and make the result as a single line.
$ tr -s '\n' ' ' < file.txt

send mail with python script to notify disk usage part 1

Reference:
http://rajivpandit.wordpress.com/2013/09/19/how-to-send-email-by-python/
https://docs.python.org/2/library/email-examples.html
                                                                                                           

[root@server1 ~]# pwd
/root
[root@server1 ~]# cat disk.txt
Filesystem      Size  Used Avail Use% Mounted on
/dev/simfs      400G  1.4G  399G   1% /
none            4.0G  4.0K  4.0G   1% /dev
none            4.0G   48K  4.0G   1% /dev/shm



[root@server1 ~]# vim mailer.py

#!/usr/bin/python
import os
import smtplib
import email.Utils
# Import the email modules we'll need
from email.mime.text import MIMEText
fp = open('disk.txt', 'rb')
msg = MIMEText(fp.read())
to = "norbuurgen@gmail.com"
FROM = "urgen@localhost.com"
server = smtplib.SMTP('localhost')
server.sendmail(FROM, [to], msg.as_string())
server.quit()


= = = = = = = = = = = ===   = = === =      === = = =   =
Following are the two ways to send email notifications by python

“””
This Script Will Send Email Using Internal Email System
In this no need any authentication or password required to send Email
Python Version 2.6
“””
from email.mime.text import MIMEText
import email.Utils
import smtplib

emailList = ["recepient1@gmail.com", "recepient2@gmail.com"] # this is List of Email Ids

for emailID in emailList:
try:
print “Sending email to … “, emailID

FROM = “email@gmail.com”
TO = emailID
message = “This Email is send by Python\n Python is Great !!!”
msg = MIMEText(message)
msg["Subject"] = “Email Notification by Python”
msg["Message-id"] = email.Utils.make_msgid()
msg["From"] = FROM
msg["To"] = TO
host = “smtp.gmail.com”
server = smtplib.SMTP(host)
server.sendmail(FROM, TO, msg.as_string())
server.quit()
print “Email Send”

except Exception, e:
print e





“””
This Script Will Send Email Using Gmail
This Required Username and password
Python Version 2.6
“””
from email.mime.text import MIMEText
from datetime import date
import smtplib

SMTP_SERVER = “smtp.gmail.com”
SMTP_PORT = 587
SMTP_USERNAME = “email@gmail.com”
SMTP_PASSWORD = “password”

EMAIL_TO = ["recepient1@gmail.com", "recepient2@gmail.com"]
EMAIL_FROM = “email@gmail.com”
EMAIL_SUBJECT = “Demo Email : “

DATE_FORMAT = “%d/%m/%Y”
EMAIL_SPACE = “, “

DATA=’This is the content of the email.’

def send_email():
msg = MIMEText(DATA)
msg['Subject'] = EMAIL_SUBJECT + ” %s” % (date.today().strftime(DATE_FORMAT))
msg['To'] = EMAIL_SPACE.join(EMAIL_TO)
msg['From'] = EMAIL_FROM
mail = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
mail.starttls()
mail.login(SMTP_USERNAME, SMTP_PASSWORD)
mail.sendmail(EMAIL_FROM, EMAIL_TO, msg.as_string())
mail.quit()
print “Email Send”

if __name__==’__main__':
send_email()


# # # # # # Send mysql status report  # # # # # # #
[root@server1 ~]# vim check.py

import smtplib
from email.mime.text import MIMEText
sql_found = False
io_found = False
with open("status.txt") as logfile:
  for line in logfile:
    if not io_found and "kSlave_IO_Running: Yes" in line:
        print "match1",line
        io_found = True
    if not sql_found and "Slave_SQL_Running: Yes" in line:
        print "match2",line
        sql_found = True

if not sql_found or not io_found:
    msg=MIMEText("Warning!! Mysql Replicatoin Stopped")
    fromaddr="root@DBausit.com"
    toaddr="norbuurgen@gmail.com"
    server = smtplib.SMTP('localhost')
    server.set_debuglevel(1)
    server.sendmail(fromaddr, [toaddr], msg.as_string())
    server.quit()
else:
    print "mysql running OK"

Ansible part 1

##############Ansible ###############
play book is composed of 1 or more plays in a list
The goal of a play is to map a group of hosts to some well defined roles, represented by things ansible calls tasks. At a basic level, a task is nothing more than a call to an ansible module, which you should have learned about in earlier chapters.


---
- hosts: webservers
  remote_user: root
  tasks:
  - name: create the new user
    yum: pkg=httpd state=latest
  - name: write the apache config file
    template: src=/srv/httpd.j2 dest=/etc/httpd.conf
    notify:
    - restart apache
  - name: ensure apache is running
    service: name=httpd state=started
  handlers:
    - name: restart apache
      service: name=httpd state=restarted

ansible 192.168.140.20 -a "/usr/bin/yum install libselinux-python"

pip install passlib

python -c "from passlib.hash import sha512_crypt; print sha512_crypt.encrypt('nepal12')"
$6$rounds=100000$KYpBC3u43XAxBJNg$7Gh04HYw3wySag8uYqeRghh0L.MtLhVTzNMEe5vr71CFWLSarvHGwrV4I.vStCXzwdPYScZFOHrfrxvl9wzMK1

copy and paste the result like below
ansible all -m user -a 'name=foo password=$6$rounds=100000$40KA9Y5UUFMh/6xC$/rUKR9Qqu7S56nQm9bV91izUA8ExDIb5rxg73QYeyHO.uGiN/9tgfgfdycsj74F36Lz6E1ZvcZf.Bz4wzwxQk0'


Play book for creating user , group with id 777 , add new user to group , copy file from local ansible server to remote client , add new user to sudoers file , install nrpe in client

---
- name: Hello World!
  gather_facts: False
  hosts: all
  vars:
      password: '$6$rounds=100000$3b69WiNTWemboVhu$IGTjv.FvMEDVzXRHEey9ddmuxKhAFL8BBL8unvCos9fcTPQkxkIEEHs1QWraTejPai5ytcq7Hs3Y3ZJ3qmRHv.'
  user: root
  tasks:
   - action: group name=demogroup1 gid=777 state=present
   - action: user name=nplinkuser1 password={{password}}
   - action: user name=nplinkuser1 groups=demogroup1 append=yes
   - copy: src=/asia dest=/
   - lineinfile: "dest=/etc/sudoers state=present regexp='^nplinkuser1' line='nplinkuser1 ALL=(ALL)  ALL'"
   - yum: name=nrpe state=latest

sed and awk

Remove multiple spaces
= = = = = = = = = = = = =

Remove leading space and number in history command output
 
history | sed 's/^ *[0-9][0-9]* *//'


root@vm2:~# cat hello 
#ab 12
cd      99
   zz    te
#ef
    test
      #tellso

root@vm2:~# cat hello  | sed 's/^\s\+//g'

#ab 12
cd      99
zz    te
#ef
test
#tellso

Combinig sed expression
root@vm2:~# cat hello  | sed 's/^\s\+//g;s/\s\+/ /g'
#ab 12
cd 99
zz te
#ef
test
#tellso


sed 'p' passwd  #prints file content but double content
sed -n '1p' file.txt  #print 1st line
sed -n  '2p' file.txt  #print 2nd line
sed -n 4,13p file.txt #print 4 to 14 line
sed -n '$p'  file.txt  #print last
sed -n '1!p' file.txt  #print all except line 1
sed -n '1,3!p' file.txt #print all except line 1 to 3


=======================using regular expression=======================
we use '-e' option when we use expression

sed -n -e '/2011/p' file.txt     # print line containing 2011
sed -n -e '/^root/p' passwd      # print lines starting with word 'root'
sed -n -e '/root$/p' passwd      # print lines Ending with word 'root'
sed -n -e '/^harke101$/p' passwd
sed -n -e '/^harke101.*$/p' passwd     # print lines Starting and Ending with word 'root'
sed -n -e '/[0-9]/p' firewall.txt     # print lines containing number 0-9
sed -n -e '/^[0-9][0-9][0-9]$/p'  firewall.txt #print beginning and ending with 3 char number
sed -n -e '/[0-9]\{3\}/p' firewall.txt # print beginning and ending with 3 char number
sed -n -e '/^[0-9]\{3\}$/p' firewall.txt # print beginning and ending with 3 char number



Find sumtotal of column

ps aux | grep apache | awk '{ sum += $6 } END { print sum }'
ls -lh php*; ls -l php* | awk '{ SUM += $5} END { print SUM/1024/1024 }'
===========================================================================



echo 'its a trap' | sed s/ra/zzz/        ##replace the word ra with zzz, matches only first occurance of Reg Ex
its a tzzzp

echo "how now brown cow" | sed s/ow/YY/  
hYY now brown cow

echo "how now brown cow" | sed s/ow/YY/g
hYY nYY brYYn cYY

sed -ie 's/ow/aagh/g' ~/temp.txt   #Make changes to the file itself

sed '11,$ d' ~/temp.txt  #delete line 11 and latter lines of file

sed '/#.*/ d'  file.txt   #delete line starting with '#'

Remove empty lines and comments {#  and ;}

 cat taste | sed '/^[#;]/d' | sed '/^$/d'      =>[#;] means lines starting with semicolon ";"  or hash " # " 


Tr command in linux
= = = = = = =  = = =  = =

Replace newline[\n]with    '  '  <space>

echo "$string" | tr '\n' ' '

Translate white-space to tabs

$ echo "This is for testing" | tr [:space:] '\t'
This is for testing

We can use -s option to squeeze the repetition of characters.

$ echo "This   is   for testing" | tr -s [:space:] '\t'
This is for testing

# Replace multiple newline with single new line


cat -s filename

cat -s 10-master.conf | grep -v "#" | cat -s

# with sed

cat filename | sed '/^$/d'

# with tr to replace multiple newline to one
cat file name | tr -s '\n'

mailscanner clamd spamassassin- Integrating mailscanner part 3

====Integrating MailScannner=====
1. Edit the file /etc/postfix/main.cf and remove the # in front of the line below

header_checks = regexp:/etc/postfix/header_checks

2. Edit the file /etc/postfix/header_checks and add the line below to the bottom of the file

/^Received:/ HOLD

3. MailScanner should now be the one to start the Postfix service. Stop the Postfix service and start the Clamd and MailScanner service in that order. Use the commands below to accomplish these.

chkconfig postfix off
chkconfig clamd on
chkconfig MailScanner on
service postfix stop
service clamd start
service MailScanner start
= = = = = clean mailscanner quarantine emails as the size increase gradually by time = = =
 # cd /etc/cron.daily/
# vim  clean.quarantine
$disabled = 0;    #uncomment
$days_to_keep   = 3;    # set value according to your needs

#./clean.quarantine       ; #to run now by hand


= = = = = clamd  may stop ,, dirty fix by periodically restarting clamd = = = = =  =
[root@mx12 xinetd.d]# crontab -l
*/3 * * * * /opt/checkclam.sh

# cat /opt/checkclam.sh
#!/bin/bash
if ! pgrep clamd > /dev/null;
then
/etc/init.d/clamd restart > /dev/null;
else
echo "OK `date +%T\ %F`" >> /program.log; #'\ ' is for space use %t for tab
fi

 = = = = = = = = = = = = = = =  = = = = = =

Perform header checks  with /etc/postfix/header_checks   file :

/^Received:/ HOLD
#                                                               HEADER_CHECKS
#
/^Subject:.*Info..P..E N I_S..--..E-N-L..A R-G-E M_E..N T-___P_I L..L_S-*/ HOLD
/^Subject:.*skinny/ HOLD
/^Subject:.*      / HOLD
/^Subject:.*Easy*/ HOLD
/^From:.*medch*/ HOLD
/^From: "expediti/ HOLD
/^From:.*newsfilm@ds02.01cloud.com/ HOLD
/^From:.*no-reply@answers.medchrome.com*/ HOLD
/^From:.*expediti/ HOLD
/^From:.*tejecraft.com.np*/ HOLD

[root@mx12 postfix]# cat check_sender
gmail.com   REJECT
hotmail.com    REJECT
yahoo.com      REJECT
medch@ds02.01cloud.com  REJECT
expediti@ds01.01cloud.com REJECT
info@tejecraft.com.np REJECT
newsfilm@ds02.01cloud.com REJECT
no-reply@answers.medchrome.com REJECT
info@wexnepal.com REJECT


[]#postmap check_sender
]#vim main.cf

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/check_sender

mailscanner clamd spamassassin-- mailscanner.conf configuratoin part 2

yum install spamassassin

Configuring MailScanner
#check below lines match
vim  /etc/MailScanner/virus.scanners.conf
clamav          /usr/lib/MailScanner/clamav-wrapper     /usr/local
clamd           /bin/false                              /usr/sbin



vim /etc/MailScanner/MailScanner.conf
# **** RULE: It must not contain any spaces! ****
%org-name% = mx12  #give your servername
%org-long-name% =          #your organization full name optional
%web-site% =   #optional
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
Quarantine Dir = /var/spool/MailScanner/quarantine
PID file = /var/run/MailScanner.pid
MTA  = postfix
Incoming Work User =
Incoming Work Group = clam
Incoming Work Permissions = 0640

Virus Scanners = clamd
Clamd Port = 3310
Clamd Lock File =
Clamd Use Threads = no  #just check leave defaults
Clamd Socket = /var/run/clamav/clamd.sock
Use SpamAssassin = yes
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin


===SETUP NECESSARY DIRECTORIES===
cd /var/spool/MailScanner/
mkdir spamassassin
chown -R postfix.clam *
chmod -R 750 *


[root@mx12 MailScanner]# ls -l
total 12
drwxr-x---  9 postfix clam   4096 Aug 21 02:27 incoming
drwxr-x--- 26 postfix apache 4096 Aug 21 00:01 quarantine
drwxr-x---  2 postfix clam   4096 Aug 21 02:17 spamassassin

mailscanner clamd spamassassin- installing clamd and mailscanner part 1

=====install  clamd and mailscanner=====

 first add epel

 yum install clamd
 3. To test ClamAV AntiVirus, type in the command clamscan in a terminal window.
 4. To update the virus database, type in the command freshclam in a terminal window.
 yum install
perl-Archive-Zip
perl-DBI
perl-DBD-SQLite
perl-Filesys-Df
perl-Net-CIDR
perl-OLE-Storage_Lite
perl-Sys-Hostname-Long
perl-Sys-SigAction
perl-MIME-tools

3. Download the latest stable version of MailScanner for RedHat, Fedora and Mandrake Linux at http://www.mailscanner.info/downloads.html.

4. Extract MailScanner using the command below.

tar -xvzf ~/Desktop/MailScanner*.gz

Replace ~/Desktop with the path of your downloaded file

5. Finally, type in the command below to install MailScanner.

cd MailScanner-4.83.5-1
yum install --nogpgcheck mailscanner* tnef*

Replace MailScanner-4.83.5-1 with the path of the extracted MailScanner archive file.

6. To test MailScanner, use the command below.

MailScanner

Errors related to configuration files are ok. Errors saying “Can’t locate xxx.pm” are perl module dependency problems so repeat step 2.

automysql backup auto mysql backup

################### Shell Bash style NO 1###############################
#!/bin/bash
#Script to make a regular copy of a mysql database and gzip it into the SAVEDIR.

USER="authorized_user"
PASSWORD="the_password"
DATABASE="database_name"
SAVEDIR="/backup"

/usr/bin/nice -n 19 /usr/bin/mysqldump -u $USER --password=$PASSWORD --default-character-set=utf8 $DATABASE -c | /usr/bin/nice -n 19 /bin/gzip -9 > $SAVEDIR/$DATABASE-$(date '+%Y%m%d-%H').sql.gz

################### Shell Bash style NO 2###############################
 #!/bin/bash
mysqldump  -u  root  -pyourP@ssword cloud | gzip > /mysqldump/cloud_db_`date '+%m-%d-%Y'`.sql.gz

##############################################################################
AutoMySQLBackup is a clever script that takes the pain out of setting up automated incremental daily, weekly, and monthly backups of MySQL databases. Its only dependency is the mysqldumpcommand, which comes with mysql-client. AutoMySQLBackup dumps your databases at whatever intervals you desire, and rolls them up into compressed tarballs. Then you can copy the tarballs to other media, and encrypt them if you wish.

Getting AutoMySQLBackup

Download AutoMySQLBackup from Sourceforge, and then unpack the tarball:
$ tar zxvf automysqlbackup-v3.0_rc6.tar.gz
Now you should have the automysqlbackup-v3.0_rc6 directory with six files in it: automysqlbackup, automysqlbackup.conf, CHANGELOG, install.sh, LICENSE, and README.
Next, read the README because it contains installation instructions and other useful information. It may not tell you everything you need to know, so hopefully this article will fill the gaps. Then your next step is to run install.sh, and this requires root privileges. If the installation script fails you can easily install AutoMySQLBackup manually by following these steps. These are run from the directory where you unpacked the tarball:
# chown root:root automysqlbackup
# chmod 0700 automysqlbackup
# cp automysqlbackup /usr/local/bin/
# mkdir /etc/automysqlbackup
# cp automysqlbackup.conf /etc/automysqlbackup/automysqlbackup.conf
# cd /etc/automysqlbackup
# cp automysqlbackup.conf servername.conf
Replace "servername.conf" with whatever you want to name your configuration file. Then you will have a copy of the original for reference, and your working configuration file.

Configuration Options

The configuration file is large and well-commented, and you need to change only a few things to start making and testing your backups. First you need to select a MySQL user that has, at a minimum, SELECT privileges, and then enter that user and user's password:
# Username to access the MySQL server e.g. dbuser
CONFIG_mysql_dump_username='db_user'
# Password to access the MySQL server e.g. password
CONFIG_mysql_dump_password='sekkritpassword'
There is a complication if you are using Parallels Plesk 10.2 or newer on your server, and you want to authenticate with the admin user. It is better to use a different MySQL user, like one you have created with minimal privileges just for AutoMySQLBackup, but if that is not possible then you can't use the plain-text admin password. Starting with version 10.2 the Plesk admin password is encrypted in /etc/psa/.psa.shadow. You can dump this password in plain text with this command if you need to recover it:
# /usr/local/psa/bin/admin --show-password
But you can't use the plain text password in your AutoMySQLBackup configuration. Instead, use the encrypted password:
# Password to access the MySQL server e.g. password
CONFIG_mysql_dump_password=`cat /etc/psa/.psa.shadow`
Your server is localhost, and you need to create or choose a directory to store your backups in:
# Host name (or IP address) of MySQL server e.g localhost
CONFIG_mysql_dump_host='localhost'
# Backup directory location e.g /backups
CONFIG_backup_dir='/home/mysqlbackups'
You have a lot of control over which databases are backed up. If you have a lot of them, then leaving CONFIG_db_names=() empty copies all of them. Then if there are any you want to exclude, just create an exclude list. One of my servers hosts over 150 virtual Web hosts, and each one has its own MySQL database, so this is a huge timesaver for me:
# List of databases for Daily/Weekly Backup e.g. ( 'DB1' 'DB2' 'DB3' ... )
# set to (), i.e. empty, if you want to backup all databases
CONFIG_db_names=()
# List of databases for Monthly Backups.
# set to (), i.e. empty, if you want to backup all databases
CONFIG_db_month_names=()
# List of DBNAMES to EXLUCDE if DBNAMES is empty, i.e. ().
CONFIG_db_exclude=('information_schema' 'test_db' 'demo_db' )
Rotation settings are straightforward. This example performs monthly backups on the 3rd of every month, weekly backups on Saturdays, daily backups are kept for 7 days, weekly backups are kept for 14 days, and monthly backups for 30 days.
# Which day do you want monthly backups? (01 to 31)
# If the chosen day is greater than the last day of the month, it will be done
# on the last day of the month.
# Set to 0 to disable monthly backups.
CONFIG_do_monthly="03"
# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
# Set to 0 to disable weekly backups.
CONFIG_do_weekly="6"
# Set rotation of daily backups. VALUE*24hours
# If you want to keep only today's backups, you could choose 1, i.e. everything older than 24hours will be removed.
CONFIG_rotation_daily=7
# Set rotation for weekly backups. VALUE*24hours
CONFIG_rotation_weekly=14
# Set rotation for monthly backups. VALUE*24hours
CONFIG_rotation_monthly=30
There are two items that control notifications. I like to see the logfiles after every run, as this example shows:
# What would you like to be mailed to you?
# - log   : send only log file
# - files : send log file and sql files as attachments (see docs)
# - stdout : will simply output the log to the screen if run manually.
# - quiet : Only send logs if an error occurs to the MAILADDR.
CONFIG_mailcontent='log'
# Email Address to send mail to? (
 user@domain.com)CONFIG_mail_address='
 carla@tuxcomputing.com'

First Run

For the first few runs, while you're getting familiar with AutoMySQLBackup, I recommend backing up just one or two small databases. It's safe and can't hurt your databases, but the larger your databases the longer it takes to try different configuration tweaks. Run it from the command line like this:
# automysqlbackup /etc/automysqlbackup/servername.conf
Then you can check your backup directory to see if it worked. It should have created all the necessary directories:
# ls /home/mysqlbackups/
daily/  
fullschema/  
latest/  
monthly/  
status/  
tmp/  
weekly/
And made entries like this, for each database you backed up, in the daily/ directory:
-rw-r--r-- 1 root root 66428 Oct 25 00:12 daily_db_name_2012-10-22_00h05m_Monday.sql.gz
AutoMySQLBackup generates a detailed log file, so there will be no mysteries about what happened if anything goes wrong.
The README offers a simple backup script:
#!/bin/sh
/usr/local/bin/automysqlbackup /etc/automysqlbackup/myserver.conf
chown root.root /var/backup/db* -R
find /var/backup/db* -type f -exec chmod 400 {} \;
find /var/backup/db* -type d -exec chmod 700 {} \;
You'll need to change myserver.conf to your configuration file name, and /var/backup/ to your own backup directory. This script ensures that the backup files owner is root, and that they are read-only, which are simple precautions against accidental changes. Don't forget to make it executable.

Scheduled Backups

Good old cron is still champ for scheduling backups. This example runs the backup script every morning at 12:05AM:
5 0 * * *  /usr/local/bin/backupscript 

Offsite Backups

Now that you have these nice database backups, what do you do with them? I use Horcrux, which we learned about last week, to encrypt and copy them to an offsite backup. So all I have to do to add my database backups to my Horcrux backup is to add this line to my Horcrux configuration:
+ /home/mysqlbackups/
Because these are compressed tarballs, you can manage them like any ordinary files and copy them to whatever backup media you want.
What about restoring from backup? AutoMySQLBackup doesn't offer any special tools for making that any easier, so you'll have to do it manually by first unzipping the backup file, and then using the mysql client to restore your database or databases. The README and forums are helpful, but what will help the most is knowing how to administer MySQL databases.