blog.plee.me About software, technology and random things

3May/200

Uploading a Snapshot to a Fresh Home Assistant OS Instance

Hi!

After finding that my previously running Home Assistant OS instance was no longer working let alone starting properly, I decided to wipe it and simply install from a fresh image today. In order to pick up where I left off, I wanted to restore from a snapshot that I made a short while ago.

Out of the box, Home Assistant OS does not seem to come with any way to upload snapshots (or any other kind of files) onto the instance. Usually, this would not be a problem, because I had previously used the Samba share add-on from the official add-on repository, but since updating it to the new repository website, the Samba share add-on seems to have disappeared.

My first alternate approach using the SSH access did not work either, as I could not use SFTP because it is not effectively using proper SSH/SFTP but an intermediate wrapper for the Home Assistant console.

The quickest way I found that had minimal impact on the system in terms of creating a mess was to use Docker and download my latest snapshot from a web server hosted somewhere else via cURL. In this case I was using a self-hosted Nextcloud instance with a shared file link, but your mileage may of course vary.

Prerequisites / Assumptions

  1. You are using the Home Assistant OS official image on a device in headless mode, so you have a minimal system without neat tools like curl or wget pre-installed.
  2. You have uploaded the snapshot file to a web server that is accessible from the Home Assistant OS system (in terms of network connectivity).

Steps

  1. Enable SSH access by following the official documentation on how to enable SSH access to the host.
    • Update from 2020-05-21: They seem to have restructured the documentation and the original instructions are no longer on that page. It used to say:
      Use a USB drive formatted with FAT, ext4, or NTFS and name it CONFIG (case sensitive). Create an "authorized_keys" file (no extension) containing your public key, and place it in the root of the USB drive. File needs to be ANSI encoded (not UTF-8) and must have Unix line ends (LF), not Windows (CR LF). [...] From the UI, navigate to the Supervisor system page and choose "Import from USB". You can now access your device as root over SSH on port 22222. Alternatively, the file will be imported from the USB when the Home Assistant OS device is rebooted.
  2. Log into the Home Assistance OS instance via SSH.
  3. Type the command "login" to enter the actual shell.
  4. Use the following command to download the snapshot file:
    docker run --rm curlimages/curl https://my.server.local/a1b2c3d4.tar > /mnt/data/supervisor/backup/a1b2c3d4.tar
    (Change URL and file names of course. The destination directory should be fine.)
  5. You might want to check file integrity for the file via md5sum or sha512sum etc.
  6. If you want to be extra tidy, you can remove the cURL Docker image again by executing
    docker image rm curlimages/curl
  7. Close the SSH session and open a new one.
  8. Do not enter the actual shell but instead execute this command to get Home Assistant to notice the newly uploaded snapshot:
    snapshots reload
  9. Now log into the Home Assistant web interface or just keep using the console and restore what you need.
  10. Done!

I hope this saved you a bunch of research because I myself could not find anything quick and practical on this topic.

Thanks for reading!

10Jun/090

How To: Migrate an Existing Windows System to Another Hard Drive Using Acronis TrueImage

Hi!

Because of a new hard drive I bought a week ago I decided to transfer my existing system, running on a 250 GB hard drive, to my new 1 TB one. I was lucky enough to at least have made some experiences with migrating an existing system to a Virtual Machine in conjunction with Acronis TrueImage Home 2009 before, so that's what came in handy for me.

What you need

  • Backup software like Acronis TrueImage Home 2009
  • BartPE with Acronis TrueImage Plug-In / bootable version of your backup software
  • Windows installation disc (preferably the same Windows version as your current system)
  • New system hard drive which is either empty or ready to be re-formatted (backup your important data on it!)

Procedure

  1. Start Acronis TrueImage Home 2009 and make a backup of your system partition.
  2. Save the backup to a partition / hard drive that you will have access to later on while using the bootable backup restorer. This means: No (TrueCrypt-)encrypted partition. Ideally it would fit on a disc or USB stick (which my didn't with a size of 7 GB). Just make sure you will be able to access it later on. I know BartPE is able to access all hard drives (without encryption at least) and should give you access to a USB drive as well, as long as you have it connected while it's booting up. If you don't want to move it over to a USB drive or DVD or anything else, there is also a nice little trick at the end of this howto: (*).
  3. Shut down your computer and make sure your new system drive is connected as the first device to avoid improper device numbering. This means using the first connector for SATA/IDE or whatever. If you are using both SATA and IDE, I don't know how that's handled. I'm just assuming you somehow have figured it out 🙂
  4. Boot from your Windows installation disc.
  5. If you haven't done it previously under Windows, partition the new system drive properly. That means to have the partitions created in the correct order. If you haven't (or aren't sure any more), delete them and do it over again just to make it right. Maybe the order is not necessary, but I had a lot of trouble with that before, so I'm just playing safe.
  6. Install Windows as usual to the point when you've started up your brand new Windows installation for the first time and are watching the Start Menu in awe.
  7. Boot from your bootable backup software (or BartPE with the plugin) and fire it up.
  8. Restore the image. Don't select MBR / Track 0, however, because we just created a proper MBR (Master Boot Record) by installing Windows.
  9. That's it! You should be done. Now a reboot should provide you with your old system on a new hard drive. Congratulations 🙂

I don't guarantee anything, and I admit to having tried several methods for half a day till I got it right 🙂 This should work fine though, because it basically is what I did the time when it finally worked.

If you have partitions with programs on it that would be started on bootup, make sure you copy it (file by file) before you start your system on the new hard drive.

While you could do that by connecting your old system drive and booting from that, then copying the files over, you could also do it beforehand by using the Windows Disk Management tool to erase all partitions and partition it properly before the Windows installation. This allows you to format the specific partitions and copy the files over to it while you're still on your old system. (*) Also, you can add the backup image onto that partition, so you don't have to burn a DVD or move the image over to a USB stick or ... (you get the point). However, if you create and format the partitions on your old system, make sure to

  • (naturally) not touch them during the Windows installation progress or your data on them will be inaccessible
  • rename your partitions properly after booting up your new system because your old Windows already assigned them (probably different) drive letters. You can do that in the Windows Disk Management tool as well.

I hope I didn't forget anything. If I did, I'll be sure to add it later on 🙂

Thanks for reading and good luck!

   
%d bloggers like this: