I want to backup my data which is presented in remote server. For that I created .sql file on particular date by using

 mysqldump -u root -h $host $db $table --where="Date='$date'"> db_backup.sql

Due to huge data I cant take the whole backup. I succeed upto creating .sql file from remote server. Now I need to append this data to the existing data in the local server. But if you open the file(.sql) it contains

DROP TABLE IF EXISTS `information`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `information` ( `Date` date DEFAULT NULL, `Name` varchar(20) DEFAULT NULL, `Cadar` varchar(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Its dropping the existing table and creating the table again. By this I am loosing my previous data. But as per my requirement I need to "append" the data without loosing the previous data. i am dumping the data into my sql using the following command

 mysql -h***.**.*.*** -u root ravi  < db_backup.sql

I removed my ip for security reasons

To make that(append) I commented the above lines manually & run the program. Its working properly. then I tried like this

open (FILE,"+<db_backup.sql") or die "Could not open file db_backup.s +ql, $!"; open (RES,">result.sql"); my $total = 0; while (my $line = <FILE>) { $line =~ s/DROP/\/*/g; $line =~ s/CREATE/\/*/g; print RES $line; }

Due to huge data opening a file and comparing each letter and writing into another file taking too long. Is there any way to reduce my code. I am using CentOS as root user.

Thanks for helping


In reply to OT: Trying to append mysql dump into DB by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.