开发者

What's the best way of backing up a rails app data?

开发者 https://www.devze.com 2023-01-15 05:28 出处:网络
I need to make a backup system for my rails app but this has to be a little special: It doesn\'t have to back up all the database info and files in a single file or folder but it has to back up the da

I need to make a backup system for my rails app but this has to be a little special: It doesn't have to back up all the database info and files in a single file or folder but it has to back up the database info and attachment files per user. I me开发者_开发技巧an, every one of this backups should be able to regenerate all the information and files for one single user.

My questions are: Is this possible? What's the best way to do it? And, if it's impossible or a bad idea at all, why is it?

Note: The database is a MySQL one. Note2: I used Paperclip for the users uploads.


Im guessing you have an app that backs up data, when a user clicks on something right? I'm thinking get all the info connected to the user(depends on how you did your user model, so maybe you should have a get_all_info method) then write it out in sql format to a file, which you save as .sql. (either using File.new or Logger.new)


I would dump the entire user object and related objects into a single xml file dump. As you go through the creation of the XML grab out all the files and write the XML + all files into one directory, then compress them.

I think there are definitely use cases to have a feature like this, but be sure to have it run in a background process and only when needed in order to not bog down the web server. Take a look at http://github.com/tobi/delayed_job or http://github.com/defunkt/resque.

0

精彩评论

暂无评论...
验证码 换一张
取 消