I want to do a database dump through Ruby scripting, but I didn't find any class or script for do that.
Ideally the dump should work for MySQL, PostgreSQL, SQLite, etc. (at least MySql and Pg). I tried with DBI but I can't.
Other way is doing table for table ... D:
Edit 1: It's only for backup, no restore. For now I have troubles with hostings, because I need to ask for permits to my IP, so I will try with SSH.
How about using exec in your script to run the mysqldump app?
exec 'mysqlinstalldir/bin/mysqldump -u username -ppassword --databases databasename'
You should be able to do the same with Postgresql and pg_dump
you can use your system tools for taking dump of database,run this script in your code may be a rake task
system "mysqldump database_name table1 table2 -u root -p password > path/to/dump/file "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With