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.sqlDue 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.sqlI 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.
In reply to OT: Trying to append mysql dump into DB by ravi45722
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |