Last active
August 29, 2015 14:19
-
-
Save lajunta/6cd15148922e090898cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
point = Time.now.strftime("%Y%m%d%H") | |
backpath="/backup/dbback/" | |
path="/tmp/"+point | |
fpath=backpath+point+".tar.gz" | |
`mkdir -p #{path}` | |
`mongodump --out #{path} --quiet` | |
`tar -C /tmp -czvf #{fpath} #{point}` | |
require 'mail' | |
smtp = { :address => 'smtp.163.com', :port => 25, :domain => '163.com', \ | |
:user_name => '[email protected]', :password => 'xxxx',\ | |
:enable_starttls_auto => true, :openssl_verify_mode => 'none' } | |
Mail.defaults { delivery_method :smtp, smtp } | |
mail = Mail.new do | |
from '[email protected]' | |
to '[email protected]' | |
subject point+" Backup is Over" | |
body 'backup is over.' | |
add_file File.expand_path(fpath) | |
end | |
mail.deliver! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment