My website runs on a dedicated Debian LAMP server . I would like to update the system (let's say I have a pretty old Debian version and I want to reinstall everything from scratch)
What strategy can I use to not have my website down while I am reinstalling everything?
Addendum
Of course I know I can buy another server in the meanwhile and change the DNS whenever it's done. But this doubles my work.
Aren't some service that maybe can act as a proxy-cacher for a limited amount of time? Maybe what does CloudFlare but caching everything not just images.
If you don't want any downtime, then really the only option is to build your new install on separate hardware and when you're happy that it's all working correctly, alter your DNS settings to point to the new server.
If you don't have another physical server, you might consider running your app on a cloud server while you do the upgrade of your physical server.
Have a second server take the load, using a load-balancer or just by re-pointing the IP for the duration of the update. In fact, if you use a load-balancer, you can then leave both servers up afterwards.
This is assuming the site isn't database-dependent. So, given the limited set of facts you gave us, this is my simple answer.
If your site is purely static, or at least is somewhat useful when setup read-only. Then you temporarily pay for some web-hosting, and then use something like wget, or similar tools to spider the static portion of your web site.
You could setup a proxy in the cloud, setup squid as a proxy to your site, adjust DNS temporarily so all access goes through the proxy, then configure Squid to operate in offline mode, after you have everything cached. You would probably want to script something that would have a browser visit all the important pages via the proxy, so everything gets into the cache.
If on a real crusade against new hardware (reasonable if you really, really don't have the budget) I would do this:
Have you considered upgrading Debian up to the latest version, though? Debian upgrades are remarkably good most of the time. If your current distribution is old enough not to be widely available on mirrors you can always use
archive.debian.org
until you reach a semi-current one.I would start with a Virtual Machine. Build up a system and then move over your current website. That should let you know what is going to give you trouble in porting your app to a new version. If you don't have another server machine at some point you are going to have to take it down to do the upgrade but knowing ahead of time where your problems are is a big step towards minimizing downtime.