Skip to content

Instantly share code, notes, and snippets.

@bricewge
Last active September 27, 2017 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bricewge/eebb34c93fd9ca04ba2aa3182011ea00 to your computer and use it in GitHub Desktop.
Save bricewge/eebb34c93fd9ca04ba2aa3182011ea00 to your computer and use it in GitHub Desktop.
Recover nixos install on Kimsufi
#!/usr/bin/env sh
# TODO Make the script fully ineractive
# TODO Use [Kimsufi's API](https://eu.api.kimsufi.com/) to do the current manual stuff
# Recover a NixOS install on Kimsufi servers by roll-back
# 1. On the Kimsufi dashboard change your boot to rescue (Netboot -> Rescue -> rescue64-pro -> Next -> Confirm)
# 2. Restart your server, ideally a soft reboot, otherwise do it from the dashboard
# 3. Connect to your server as root by SSH and run this script
# 4. Revert your boot option back to your HDD and restart your server
mount -o subvol=root /dev/sda2 /mnt
mount -o subvol=home /dev/sda2 /mnt/home
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
ls -lt /mnt/nix/var/nix/profiles/
# Choose the configuration to which you want to roll-back from the result of ls
export ROLLBACK_VERSION=46
LC_ALL=C chroot /mnt /bin/sh
NIXOS_INSTALL_BOOTLOADER=1 /nix/var/nix/profiles/system-${ROLLBACK_VERSION}-link/bin/switch-to-configuration boot
exit
umount -R /mnt
# shutdown -r now
# Ressources:
# - https://www.codejam.info/2015/12/installing-nixos-on-a-kimsufi.html
# - https://nixos.org/nix-dev/2015-July/017604.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment