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...@googlemail.com> wrote:
> On 6 September 2010 10:25, Daniel Morigan <daniel.mori...@gmail.com> 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@googlegroups.com.
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.
No comments:
Post a Comment