Ask A Question

Notifications

You’re not receiving notifications from this thread.

Hourly Production Server Database And File Backups Discussion

Chris Oliver asked in General

Thank you for this! I should get this up and running on a site I run for a complex fantasy football league...I've been meaning to with Cron jobs and whatnot, but it's just such a hassle and, so far, there hasn't been much site traffic, but still...a catastrophe could be hiding around an upcoming corner!

Reply

Glad I could help! :)

Reply

s3.path = "/production/database"
Is the the end point or path with the bucket? I get The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

Does one need to set any permission on the bucket?

Reply

Solved, just needed to fix my bucket region.

Reply

For anyone getting this warning.

[fog][WARNING] fog: the specified s3 bucket name(BUCKET_NAME) is not a valid dns name, which will negatively impact performance.

Fog does not like dash in the the BUCKET_NAME. It's best to use BUCKETNAME.

Reply

Good find! Thanks for sharing this.

Reply
Anthony Candaele Anthony Candaele

Thanks Chris for this very useful guide. I just implemented the Backup gem and the cron job. And it is successfully storing a backup of the database to Amazon S3.

At the end of the guide you say:

"Always be sure to test your backups and make sure you can safely restore from them!"

So how do you restore your database with a backup on Amazon S3?

greetings,

Anthony

Reply

Depends on what you're backing up, but for example, you can restore a mysql database with a sql file like this: http://stackoverflow.com/a/...

Reply

Hello Chris, thanks for this useful website! I am getting the following error with Amazon S3: AuthorizationHeaderMalformed<message>The authorization header is malformed; the authorization header requires three components: Credential, SignedHeaders, and Signature.</message>

I have tried to use GIYF without success. I have paperclip gem in my rails app working fine with the same S3 credentials and same bucket but backup gem is not! Can you help me please?

Reply

Interesting. I can't think of much except for maybe having a typo somewhere.

Reply

Code was broken

Reply
Andrew Shaydurov Andrew Shaydurov

Just keep it more simple with https://backup.foundation

Reply

is there a way to use backup gem on heroku instance and setup? thx

Reply
Jordano Moscoso Jordano Moscoso

Use pg backups. Is easier on heroku.

Reply

Hey Chris, Backup gem link is broken, new link should go here: https://github.com/backup/b...

Reply

[fog][WARNING] fog: followed redirect to my-bucket.s3-eu-west-1.amaz..., connecting to the matching region will be more performant
[info] CloudIO::Error: Retry #1 of 10
[info] Operation: PUT 'path/production_backup.tar'
[info] --- Wrapped Exception ---
[info] Excon::Errors::BadRequest: Expected(200) <=> Actual(400 Bad Request)
[info] excon.error.response
[info] :body=> "\n<error>IncompleteBody<message>The request body terminated unexpectedly<

Any Idea?

Reply

Hi Chris, my application db size is 84 GB. If the backup runs every one hour will it not hamper the application. What should be the ideal way?

Reply

Lots of options. Depending on how long it takes you might want to do this every 4 hours or something instead. You might want to do a live replica database for realtime backups to another server and then archive a copy of it nightly.

Reply
Jordano Moscoso Jordano Moscoso

You should use database replicas and make partial and transaction backups. I did that on MS SQL server but i don't know how that would be achieved on Postgres or Mysql.

Reply
Ali Ahmed Ali Ahmed

Hey Chris this is interesting. But I need the restore functionality. Do you think you have a way arounf?

Reply

You've just got to download the backup, extract it, and reimport your database and do the same for whatever else you may have backed up.

Reply

Hey Chris! Are you still using this method in production? I haven't been able to get the backup gem to work with ruby 2.4.x, have you gotten it to work with rails 5.1 and a recent ruby?

Reply

gem install backup -v5.0.0.beta.1 will work with Ruby 2.4.x

Reply

Hey Chris, how to do a incremental backup. Is there best tools to do that or procedure to do with postgres commands like WAL to get incremental backup.

Reply

The Backup gem is in "maintenance-only" phase now. Is there a newer suggested gem to replace this functionality with Rails projects?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.