Links replacement on sql dump

Hi All
I have dump of mysql DB (Joomla), and I found out that there is absolute links on the DB not with the domain name but the IP address ex:

,(115205,'http://54.5.17.148//index.php/restoflink
,(115205,'http://54.5.17.149/index.php/restoflink,(115205,'http://54.5.17.149/index.php/restoflink.....

There is two IP's always in the absolute links because the website is behind a load balancer, the issue caused showing the IP address instead of the domain name in the browser URL bar.
I checked the absolute links with the IP and I found that there is four possibilities :

http://54.5.17.148//
http://54.5.17.148/
http://54.5.17.149/
http://54.5.17.149//

What's the right way to replace those links with the domain name instead ?,

thanks. in advance.

Are those actual values in a table or they actually commented out in the dump file?

What do those names resolve to?

Where do you want those links replaced? In the DB? In the dump file?

those value are not commented but exist in the DB tables.
The name are the two IP servers because behind the load balancer.
I want to replace on the dump file then I will import it to DB.

Try

sed -r 's#/+54.5.17.14[89]/+#/domain.com/#g' file
,(115205,'http:/domain.com/index.php/restoflink
,(115205,'http:/domain.com/index.php/restoflink,(115205,'http:/domain.com/index.php/restoflink.....
1 Like

thanks this is work for the two IP I posted but actually the real IP looks like this:
55.58.26.211
55.58.16.247
how I can modify the cmd to support those exact two IPs ?

What about applying some creativity yourself?
And, why didn't you post the real IP in the first place?

Sorry, I will make my self creative and let me know if it's right :wink:

Good approach. We will check your solutions.

I tried this but it didn't work

sed -r 's#/+55.58.[21][6].[2][14][17]]/+#/domain.com/#g' file

Please use code tags as required by forum rules!

Not too bad. Remove the double closing square bracket at the end, and it will fly. The [6] and [2] aren't necessary, make them 6 and 2.
That regex will also match e.g. 55.58.16.211 or ...217 ; so if chances are there other, unwanted matches possible und you want exactly and only the two mentioned, other measures need to be taken.
Please be aware that the . in the regex will match any char including dot. If it HAS to be "." , make it \. in the regex.

1 Like
sed -r 's#/+55.58.[21]6.2[14][17]/+#/domain.com/#g' file

there is any way to know if the cmd did the right Job, the dump is 15MB

Either use a representative subset of the file, or open the resulting file and do a spot check on those addresses.
Of course, you could grep for the original IP; if they have disappeared, things should be well.