Socket
Book a DemoInstallSign in
Socket

mypg

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mypg

0.0.4
bundlerRubygems
Version published
Maintainers
1
Created
Source

Mypg

Easy backup for Rails applications with PostgreSQL database.

Installation

Add this line into your application's Gemfile:

gem 'mypg'

Install the gem with Bundler:

$ bundle

Configuration

And then add some settings:

$ rails g mypg:install

This will create a configuration file in config/mypg.yml who looks like this:

# target_directory: '/path/to/backup'
# files_to_keep:    7

Just enter a valid directory to save your backup files.

Note: If not specified, the amount of files that will be saved is 7.

How To

Backup

Go to your Rails root directory and run this:

$ rake db:backup RAILS_ENV=production

This command will create a .pgsql file in the directory with your database's structure and data. Moreover, will delete the older files wich exceed the amount to be saved.

Pro Tip

You can create automatic daily backups just setting up a task on Cron:

$ crontab -e

Insert this and save:

# m h  dom mon dow   command
0 0 * * * cd ~/my/rails/root && rake db:backup RAILS_ENV=production

With that, every day in the midnight (server's time) Cron will perform your backup task automatically.

Restore

If you wish to restore some saved backup, go to your Rails root directory and run this:

$ rake db:restore 'relative/target/directory/to/backup/database_x.pgsql' RAILS_ENV=production

This command will restructure the production database and restore all the data from backup file.

Note: The path for the backup file must be relative to the current directory in the console.

Thanks

Leonardo Ávila for contributing in the README translation and revision.

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Added some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 02 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.