Changeset 323
- Timestamp:
- 07/22/06 23:25:39 (2 years ago)
- Location:
- mysqldump2email/trunk
- Files:
-
- 2 modified
-
config.yaml.sample (modified) (1 diff)
-
mysqldump2email (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mysqldump2email/trunk/config.yaml.sample
r322 r323 1 username: your-mysql-username 2 password: your-mysql-password 1 mysqldump: 2 command: /usr/local/bin/mysqldump 3 username: your-mysql-username 4 password: your-mysql-password 5 #host: localhost 3 6 4 mailfrom: address@example.com 5 mailto: address@example.com 6 mailroute: 7 via: smtp 8 host: localhost:25 9 #mailroute: 10 # via: sendmail 7 zip: 8 command: /usr/local/bin/zip 9 # if encryption needed 10 #password: your-zip-password 11 11 12 mysqldump-command: /usr/local/bin/mysqldump 13 zip-command: /usr/local/bin/zip 12 mail: 13 from: address@example.com 14 to: address@example.com 15 route: 16 via: smtp 17 host: localhost:25 18 #route: 19 # via: sendmail 14 20 15 # if encryption needed 16 #zip-password: your-zip-password 21 tmpdir: /tmp -
mysqldump2email/trunk/mysqldump2email
r322 r323 25 25 my $zipfile = dump_mysql($cfg, $dt); 26 26 27 my $mailroute = $cfg->{mailroute} || { via => 'smtp', host => 'localhost' }; 27 my $cfg_mail = $cfg->{mail} 28 or die 'No "mail" setting found in config.yaml'; 29 30 my $mailroute = $cfg_mail->{route} || { via => 'smtp', host => 'localhost' }; 28 31 MIME::Lite->send($mailroute->{via}, 29 32 $mailroute->{host} ? ($mailroute->{host}) : ()); … … 31 34 my $msg = MIME::Lite->new( 32 35 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}, 35 38 Subject => encode('MIME-Header', __PACKAGE__), 36 39 Type => 'multipart/mixed', … … 51 54 sub dump_mysql { 52 55 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 53 61 my $ts = $dt->ymd('') . $dt->hms(''); 54 55 62 my $tmpdir = $cfg->{'tmpdir'} || '/tmp'; 56 63 my $fname = __PACKAGE__ . '.' . $ts; … … 58 65 my $zipfile = $dumpfile . '.zip'; 59 66 60 system($cfg ->{'mysqldump-command'} || 'mysqldump',67 system($cfg_mdump->{command} || 'mysqldump', 61 68 '--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}) : ()), 64 72 '--result-file=' . $dumpfile) == 0 65 73 or die 'Failed to execute "mysqldump" command'; 66 system($cfg ->{'zip-command'} || 'zip',74 system($cfg_zip->{command} || 'zip', 67 75 '-9mqj', 68 ($cfg ->{'zip-password'} ? ('-P', $cfg->{'zip-password'}) : ()),76 ($cfg_zip->{password} ? ('-P', $cfg_zip->{password}) : ()), 69 77 $zipfile, $dumpfile) == 0 70 78 or die 'Failed to execute "zip" command'; … … 126 134 =over 4 127 135 136 =item mysqldump: 137 138 =over 4 139 140 =item command 141 142 Set the full path of C<mysqldump> command in your box. 143 128 144 =item username, password 129 145 130 146 Set your username and password for MySQL. 131 147 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 150 Set your hostname of MySQL server. 151 152 =back 153 154 =item zip: 155 156 =over 4 157 158 =item command 159 160 Set the full path of C<zip> command in your box. 161 162 =item password (Optional) 149 163 150 164 Set the password for encrypting/decrypting zip files. If not set, no … … 153 167 =back 154 168 169 =item mail: 170 171 =over 4 172 173 =item from 174 175 Set email address for this application, which is used as C<From:> header. 176 177 =item to 178 179 Set the target email address, which is sent emails to. 180 181 =item route 182 183 Set how to send emails. Default is to use SMTP. 184 185 =back 186 187 =item tmpdir: 188 189 Set the temporary directory for this application. 190 191 =back 192 155 193 =head1 DEVELOPMENT 156 194 … … 158 196 subversion repository: 159 197 160 http://code.as-is.net/svn/public/mysqldump2email/trunk198 http://code.as-is.net/svn/public/mysqldump2email/trunk 161 199 162 200 You can browse the files via viewvc from the following: 163 201 164 http://code.as-is.net/viewvc/public/browse/mysqldump2email/trunk/202 http://code.as-is.net/viewvc/public/browse/mysqldump2email/trunk/ 165 203 166 204 Any comments, suggestions, or patches are welcome.
![(please configure the [header_logo] section in trac.ini)](/public/chrome/common/trac_banner.png)