Report this

What is the reason for this report?

Dealing with IP address changes when restore from backup or snapshot

Posted on February 11, 2014

I would like to create a ‘production’ environment that hosts a few of my websites. This would involve creating a droplet and configuring apache/nginx, bind/dns, mysql, exim/dovecot, vsftpd, etc.

I would then take a snapshot/backup of the droplet to use as a failover.

Since there is no guarantee you will get the same IP address when scaling or creating a new droplet from a previous snapshot, I wanted to know the best method to deal with the IP change.

Would something simple like find/replace using grep or another utility from the command line work, or would it require a more complex solution?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there. You could try this combo of find and sed to find/replace: <br> <br>find . -type f -name ‘.ext’ -exec sed -i ‘s|0.0.0.0|123.123.123.123|g’ {} ; <br> <br>Where 0.0.0.0 is your old IP and 123.123.123.123 is your new one; and -name '.ext’ is file extension (probly best to use . if you want to change everything, including logs—might take a while)… <br> <br>Good luck!

@nooblag Thank you for that example, I think that has me started in the right direction. I would use . and exclude multiple directories to speed things up. <br> <br>With not being able to secure IP address for our droplets, surely this has been dealt with before. Everyone, please do share how you would deal with changing all occurrences of an old IP to the new one in a droplet after you’ve already setup and configured everything.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.