How to do bare metal restore?

How does one do what I call a "bare metal restore" of a linode server? When I first set up my server I followed the Linode "Getting Started" and "Securing Your Server" instructions and created my user account. I then created a snapshot of the server. Now, anytime that I restore this snapshot, I have a clean server that I can install my website and all its packages onto.

My problem is that whenever I want to wipe my server and start over, I have to shut the server down, remove my main disk and swap disk images, restore my snapshot, resize my main disk image, change my disk and configuration profile labels, delete my old config profile, and reboot the server. Doing this all by hand is time-consuming and error-prone. Is there some way I can automate this process I've just described? I've looked through the documentation and while it's well-written, it's still all very confusing. This doesn't seem like a job for a stackscript as I need to resize my disk images and change the labels. Does Linode provide the tools to do what I need?

Thanks.

3 Replies

https://www.linode.com/api will get you part of the way, though you have to restore the backup by hand.

Really, you're probably way better off actually codifying your config with Puppet/Chef/Salt/Ansible/etc rather than trusting the gold-master and hoping you remember what you did to set up the configs inside it.

  • Les

Thanks. Actually, after looking at the API, if I created an image of the disk (rather than a snapshot), I could use disk.createfromimage to restore from that image.

In essence, are you suggesting that I use the Linode API simply to create my configuration profile (using a base Linux distro) and resize my disks and then use a CM tool to perform all the initial "Getting Started" and "Securing Your Server" steps as well as installing all of my packages? That might make good sense. I think I'll look into Ansible as I'll only have at most five servers I'll ever need to configure. Chef and Puppet would probably be overkill.

As an aside, do you prefer a CM like Ansible to shell scripts? I would think that Bash scripts might be a better option since you then have the option to use them to create a Linode StackScript.

Thanks again.

I'd say that Puppet isn't overkill, I'm currently using it to configure my two Macs.

As far as Ansible vs bash scripts, Ansible is leaps and bounds better. It does a much better job handling idempotency, so if there's an issue you can fix it and safely re-run the provisioning, and it has much better logging / validation baked in that will preserve your sanity.

When I used Ansible, I had a tiny StackScript that essentially did "git clone MYANSIBLEREPO" and then applied the playbooks for the server.

StackScripts are pretty inflexible, I much prefer to use them as a springboard to kick off the real provisioning.

  • Les

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct