Hi, I want to create an administration panel in the application that would allow to backup the database and some other stuff. How can I create a backup and send it to some place (s3, ftp) or download it as a file to the local computer. Daniel -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 September 2010 10:25, Daniel Morigan <daniel.morigan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, I want to create an administration panel in the application that > would allow to backup the database and some other stuff. How can I > create a backup and send it to some place (s3, ftp) or download it as > a file to the local computer.I guess it will depend on your database. This is the code for a backup action in my app. I wrote it some time ago when I had little experience so it may well not be the best way. def backup # get database name from one of the models # there must be a better way of doing this dbname = Act.configurations[RAILS_ENV][''database''] if dbname # delete backup files created on previous backup actions Dir.glob("#{dbname}_*.sql").each { |f| File.delete(f) } filename = "#{dbname}_" + Time.new.strftime(''%Y%m%d_%H%M%S'') + ''.sql'' @answer = system "mysqldump -u xxxxx -pxxxxx #{dbname} > #{filename}" if @answer send_file "#{filename}" # note cannot delete the file here as the file is sent in -background else # dump failed flash[:error] = "Mysql dump failed" redirect_to :action => :index end end end Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The project is on heroku and PostgreSQL is used there. I also use PostgreSQL on my local. I thing creating/editing/deleting files on heroku is forbidden On 6 Wrz, 12:36, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 6 September 2010 10:25, Daniel Morigan <daniel.mori...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, I want to create an administration panel in the application that > > would allow to backup the database and some other stuff. How can I > > create a backup and send it to some place (s3, ftp) or download it as > > a file to the local computer. > > I guess it will depend on your database. This is the code for a > backup action in my app. I wrote it some time ago when I had little > experience so it may well not be the best way. > > def backup > # get database name from one of the models > # there must be a better way of doing this > dbname = Act.configurations[RAILS_ENV][''database''] > if dbname > # delete backup files created on previous backup actions > Dir.glob("#{dbname}_*.sql").each { |f| File.delete(f) } > filename = "#{dbname}_" + Time.new.strftime(''%Y%m%d_%H%M%S'') + ''.sql'' > @answer = system "mysqldump -u xxxxx -pxxxxx #{dbname} > #{filename}" > if @answer > send_file "#{filename}" > # note cannot delete the file here as the file is sent in -background > else > # dump failed > flash[:error] = "Mysql dump failed" > redirect_to :action => :index > end > end > end > > Colin-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Daniel Morigan wrote:> The project is on heroku and PostgreSQL is used there. I also use > PostgreSQL on my local. I thing creating/editing/deleting files on > heroku is forbiddenIt is. But Heroku already provides Rake tasks to back up the DB. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.