Changeset 323

Show
Ignore:
Timestamp:
07/22/06 23:25:39 (2 years ago)
Author:
ogawa
Message:

Refine configuration options.

Location:
mysqldump2email/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • mysqldump2email/trunk/config.yaml.sample

    r322 r323  
    1 username: your-mysql-username 
    2 password: your-mysql-password 
     1mysqldump: 
     2  command: /usr/local/bin/mysqldump 
     3  username: your-mysql-username 
     4  password: your-mysql-password 
     5  #host: localhost 
    36 
    4 mailfrom: address@example.com 
    5 mailto:   address@example.com 
    6 mailroute: 
    7   via:  smtp 
    8   host: localhost:25 
    9 #mailroute: 
    10 # via:  sendmail 
     7zip: 
     8  command: /usr/local/bin/zip 
     9  # if encryption needed 
     10  #password: your-zip-password 
    1111 
    12 mysqldump-command: /usr/local/bin/mysqldump 
    13 zip-command:       /usr/local/bin/zip 
     12mail: 
     13  from: address@example.com 
     14  to:   address@example.com 
     15  route: 
     16    via:  smtp 
     17    host: localhost:25 
     18  #route: 
     19  #  via:  sendmail 
    1420 
    15 # if encryption needed 
    16 #zip-password: your-zip-password 
     21tmpdir: /tmp 
  • mysqldump2email/trunk/mysqldump2email

    r322 r323  
    2525my $zipfile = dump_mysql($cfg, $dt); 
    2626 
    27 my $mailroute = $cfg->{mailroute} || { via => 'smtp', host => 'localhost' }; 
     27my $cfg_mail = $cfg->{mail} 
     28    or die 'No "mail" setting found in config.yaml'; 
     29 
     30my $mailroute = $cfg_mail->{route} || { via => 'smtp', host => 'localhost' }; 
    2831MIME::Lite->send($mailroute->{via}, 
    2932                 $mailroute->{host} ? ($mailroute->{host}) : ()); 
     
    3134my $msg = MIME::Lite->new( 
    3235    Date => DateTime::Format::Mail->format_datetime($dt), 
    33     From => __PACKAGE__ . ' <' . $cfg->{mailfrom} . '>', 
    34     To => $cfg->{mailto}, 
     36    From => __PACKAGE__ . ' <' . $cfg_mail->{from} . '>', 
     37    To => $cfg_mail->{to}, 
    3538    Subject => encode('MIME-Header', __PACKAGE__), 
    3639    Type => 'multipart/mixed', 
     
    5154sub dump_mysql { 
    5255    my ($cfg, $dt) = @_; 
     56    my $cfg_mdump = $cfg->{mysqldump} 
     57        or die 'No "mysqldump" setting found in config.yaml'; 
     58    my $cfg_zip = $cfg->{zip} 
     59        or die 'No "zip" setting found in config.yaml'; 
     60 
    5361    my $ts = $dt->ymd('') . $dt->hms(''); 
    54  
    5562    my $tmpdir = $cfg->{'tmpdir'} || '/tmp'; 
    5663    my $fname = __PACKAGE__ . '.' . $ts; 
     
    5865    my $zipfile = $dumpfile . '.zip'; 
    5966 
    60     system($cfg->{'mysqldump-command'} || 'mysqldump', 
     67    system($cfg_mdump->{command} || 'mysqldump', 
    6168           '--all-databases', 
    62            '--user=' . $cfg->{username}, 
    63            '--password=' . $cfg->{password}, 
     69           ($cfg_mdump->{username} ? ('--user=' . $cfg_mdump->{username}) : ()), 
     70           ($cfg_mdump->{password} ? ('--password=' . $cfg_mdump->{password}) : ()), 
     71           ($cfg_mdump->{host} ? ('--host=' . $cfg_mdump->{host}) : ()), 
    6472           '--result-file=' . $dumpfile) == 0 
    6573        or die 'Failed to execute "mysqldump" command'; 
    66     system($cfg->{'zip-command'} || 'zip', 
     74    system($cfg_zip->{command} || 'zip', 
    6775           '-9mqj', 
    68            ($cfg->{'zip-password'} ? ('-P', $cfg->{'zip-password'}) : ()), 
     76           ($cfg_zip->{password} ? ('-P', $cfg_zip->{password}) : ()), 
    6977           $zipfile, $dumpfile) == 0 
    7078        or die 'Failed to execute "zip" command'; 
     
    126134=over 4 
    127135 
     136=item mysqldump: 
     137 
     138=over 4 
     139 
     140=item command 
     141 
     142Set the full path of C<mysqldump> command in your box. 
     143 
    128144=item username, password 
    129145 
    130146Set your username and password for MySQL. 
    131147 
    132 =item mailfrom 
    133  
    134 Set email address for this application, which is used as C<From:> header. 
    135  
    136 =item mailto 
    137  
    138 Set the target email address, which is sent emails to. 
    139  
    140 =item mailroute 
    141  
    142 Set how to send emails. Default is to use SMTP. 
    143  
    144 =mysqldump-command, zip-command 
    145  
    146 Set the path to C<mysqldump> and C<zip> commands. 
    147  
    148 =zip-password (Optional) 
     148=item host (Optional) 
     149 
     150Set your hostname of MySQL server. 
     151 
     152=back 
     153 
     154=item zip: 
     155 
     156=over 4 
     157 
     158=item command 
     159 
     160Set the full path of C<zip> command in your box. 
     161 
     162=item password (Optional) 
    149163 
    150164Set the password for encrypting/decrypting zip files.  If not set, no 
     
    153167=back 
    154168 
     169=item mail: 
     170 
     171=over 4 
     172 
     173=item from 
     174 
     175Set email address for this application, which is used as C<From:> header. 
     176 
     177=item to 
     178 
     179Set the target email address, which is sent emails to. 
     180 
     181=item route 
     182 
     183Set how to send emails. Default is to use SMTP. 
     184 
     185=back 
     186 
     187=item tmpdir: 
     188 
     189Set the temporary directory for this application. 
     190 
     191=back 
     192 
    155193=head1 DEVELOPMENT 
    156194 
     
    158196subversion repository: 
    159197 
    160   http://code.as-is.net/svn/public/mysqldump2email/trunk 
     198http://code.as-is.net/svn/public/mysqldump2email/trunk 
    161199 
    162200You can browse the files via viewvc from the following: 
    163201 
    164   http://code.as-is.net/viewvc/public/browse/mysqldump2email/trunk/ 
     202http://code.as-is.net/viewvc/public/browse/mysqldump2email/trunk/ 
    165203 
    166204Any comments, suggestions, or patches are welcome.