Skip to content

Instantly share code, notes, and snippets.

@lajunta
Last active August 29, 2015 14:19
Show Gist options
  • Save lajunta/6cd15148922e090898cf to your computer and use it in GitHub Desktop.
Save lajunta/6cd15148922e090898cf to your computer and use it in GitHub Desktop.
#!/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