Coder Social home page Coder Social logo

programaelfuturo / heroku-mongo-backup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from entrefuse/heroku-mongo-backup

0.0 2.0 0.0 107 KB

Backup mongodb on Heroku and push it to S3 or FTP with cron task.

Home Page: https://github.com/alexkravets/heroku-mongo-backup

heroku-mongo-backup's Introduction

heroku-mongo-backup โ€” backup mongodb on Heroku and push it to S3 or FTP storage

heroku-mongo-backup does:

  1. Backup mongodb collections to one file;
  2. Compress backup file with gzip;
  3. Push backup to the specified S3 bucket or FTP server;

Why not mongodump command?

mongodump command is not available on Heroku side. If you don't want to setup third party backup service for every project heroku-mongo-backup may be helpful.

Configuration

Add gem to the Gemfile: gem "heroku-mongo-backup" - if everything's okay rake -T command should show rake mongo:backup rake tasks.

For S3 support heroku-mongo-backup requires s3 or aws-s3 or fog library. One of those should be in Gemfile, if you don't care add fog it's seems to be the most advanced.

Configure heroku scheduler to run mongo:backup rake task. Or if cron is used add backup task to /lib/tasks/cron.rake file:

desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
  Rake::Task['mongo:backup'].invoke
end

Set Heroku environment variables:

heroku config:add S3_BACKUPS_BUCKET=_value_ S3_KEY_ID=_value_ S3_SECRET_KEY=_value_ MONGO_URL=_value_

On MONGO_URL place anyone of these is assaptable: MONGOHQ_URI or MONGOLAB_URI.

For FTP set these variables:

heroku config:add UPLOAD_TYPE=ftp FTP_HOST=_host_ FTP_PASSWORD=_pass_ FTP_USERNAME=_user_

Rake Commands

  • heroku run rake mongo:backup

If you want to automatically remove old backup files pass MAX_BACKUPS parameter to the rake command:

  • heroku run rake mongo:backup MAX_BACKUPS=7

Restore from backup:

  • heroku run rake mongo:restore FILE=backup-file-name.gz

If you want to restore from local file run:

  • rake mongo:restore LOCAL=/absolute/path/to/<backup-file.gz>

For Rails 2 add this to your Rakefile to import rake tasks:

import File.expand_path(File.join(Gem.datadir('heroku-mongo-backup'), '..', '..', 'lib', 'tasks', 'heroku_mongo_backup.rake'))

Gem Contributors

  1. alexkravets - slatestudio.com - gem itself with S3 support
  2. matyi - FTP support
  3. stefl - stef.io - Rails is not required for production
  4. moonhouse - moonhouse.se - default config improvement
  5. wolfpakz - Rails2 support
  6. solacreative - Max backups feature for aws/s3 and s3 gems

heroku-mongo-backup's People

Contributors

jhoffner avatar matyi avatar wolfpakz avatar stefl avatar taromurao avatar

Watchers

James Cloos avatar Hernan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.