Add to nav, fix typos, and minor layout changes

This commit is contained in:
Fabian Affolter 2017-04-29 12:20:29 +02:00
parent d2b94034c1
commit d58e145e3c
No known key found for this signature in database
GPG Key ID: DDF3D6F44AAB1336
2 changed files with 49 additions and 31 deletions

View File

@ -9,16 +9,14 @@ sharing: true
footer: true footer: true
--- ---
Backing upyour Home Assistant configuration to USB. Backing upyour Home Assistant configuration to USB. A good plus side is that you don't need to mask all your passwords since the backup is locally at your home/residence.
A good plus side is that you don't need to mask all your passwords since the backup is locally at your home/residence.
### {% linkable_title Requirements %} ### {% linkable_title Requirements %}
First you need a USB stick. Once you have one you need to prepare it to be used on your device. First you need a USB stick. Once you have one you need to prepare it to be used on your device.
Once connected you want to format/work with the drive. To know what path it is in, you can check with dmesg. Once connected you want to format/work with the drive. To know what path it is in, you can check with `dmesg`.
``` ```bash
root@hassbian:/media# dmesg|grep sd # dmesg | grep sd
[ 0.909712] sdhci: Secure Digital Host Controller Interface driver [ 0.909712] sdhci: Secure Digital Host Controller Interface driver
[ 0.916414] sdhci: Copyright(c) Pierre Ossman [ 0.916414] sdhci: Copyright(c) Pierre Ossman
[ 0.923366] sdhost: log_buf @ bac07000 (fac07000) [ 0.923366] sdhost: log_buf @ bac07000 (fac07000)
@ -34,20 +32,22 @@ root@hassbian:/media# dmesg|grep sd
[726259.209004] sd 0:0:0:0: [sda] Attached SCSI removable disk [726259.209004] sd 0:0:0:0: [sda] Attached SCSI removable disk
``` ```
Here we see we have a drive on /dev/sda1. We assume you created a partition on the drive to start with. This can be any type of partition. Preffered is a linux one so you can set permissions! Here we see we have a drive on `/dev/sda1`. We assume you created a partition on the drive to start with. This can be any type of partition. Preferred is a Linux filesystem type so you can set permissions!
Mount the drive (as root) to /media
``` Mount the drive (as root) to `/media`
root@hassbian:~# mount /dev/sda1 /media/
```bash
# mount /dev/sda1 /media/
``` ```
### {% linkable_title Prepare USB Stick %} ### {% linkable_title Prepare USB Stick %}
Cd into it and create a folder called 'hassbackup' and chown it to the user that runs homeassistant. In my case group and user are both homeassistant. Change into it and create a folder called `hassbackup` and change the ownership to the user that runs Home Assistant. In my case group and user are both `homeassistant`.
```
root@hassbian:~# cd /media/ ```bash
root@hassbian:/media# mkdir hassbackup # cd /media/
root@hassbian:/media# chown homeassistant:homeassistant hassbackup/ /media# mkdir hassbackup
root@hassbian:/media# ls -al /media# chown homeassistant:homeassistant hassbackup/
/media# ls -al
total 28 total 28
drwxr-xr-x 4 root root 4096 Apr 29 10:36 . drwxr-xr-x 4 root root 4096 Apr 29 10:36 .
drwxr-xr-x 22 root root 4096 Mar 22 18:37 .. drwxr-xr-x 22 root root 4096 Mar 22 18:37 ..
@ -59,41 +59,58 @@ You can ignore 'lost+found'.
### {% linkable_title Install Dependency %} ### {% linkable_title Install Dependency %}
In order to preserve space on your drive we use zip. Install that too. In order to preserve space on your drive we use zip. Install that too.
```
root@hassbian:/media# apt-get install zip ```bash
/media# apt-get install zip
Reading package lists... Done Reading package lists... Done
Building dependency tree Building dependency tree
etc etc etc [...]
Setting up zip (3.0-8) ... Setting up zip (3.0-8) ...
``` ```
### {% linkable_title Install & run script %} ### {% linkable_title Install and run script %}
Become the homeassistant user and place the following [script](https://gist.github.com/riemers/041c6a386a2eab95c55ba3ccaa10e7b0) to a place of your liking. Become the `homeassistant` user and place the following [script](https://gist.github.com/riemers/041c6a386a2eab95c55ba3ccaa10e7b0) to a place of your liking.
Don't forget to 'chmod +x usb_backup.sh'
Open up the file and change the paths you want to use, then simply run the usb_backup.sh ```bash
# wget https://gist.githubusercontent.com/riemers/041c6a386a2eab95c55ba3ccaa10e7b0/raw/86727d4e72e9757da4f68f1c9d784720e72d0e99/usb_backup.sh
``` ```
homeassistant@hassbian:~ $ .homeassistant/extraconfig/shell_code/usb_backup.sh
Make the downloaded script executable.
```bash
# chmod +x usb_backup.sh
```
Open up the file and change the paths you want to use, then simply run the `./usb_backup.sh`.
```bash
$ .homeassistant/extraconfig/shell_code/usb_backup.sh
[i] Creating backup [i] Creating backup
[i] Backup complete: /media/hassbackup/hass-config_20170429_112728.zip [i] Backup complete: /media/hassbackup/hass-config_20170429_112728.zip
[i] Keeping all files no prunning set [i] Keeping all files no prunning set
``` ```
### {% linkable_title Crontab %} ### {% linkable_title Crontab %}
In order for this to automaticly make a backup every night at 3, you can add a crontab for it as the homeassistant user. In order for this to automatically make a backup every night at 3 am, you can add a crontab for it as the `homeassistant` user.
Change below path to where you placed the usb_backup.sh and run the following line. Change below path to where you placed the `usb_backup.sh` and run the following line.
``` ```bash
(crontab -l 2>/dev/null; echo "0 3 * * * /home/homeassistant/.homeassistant/extraconfig/shell_code/usb_backup.sh") | crontab - (crontab -l 2>/dev/null; echo "0 3 * * * /home/homeassistant/.homeassistant/extraconfig/shell_code/usb_backup.sh") | crontab -
``` ```
### {% linkable_title Auto mount %} ### {% linkable_title Auto mount %}
This does not automaticly mount your usb drive at boot. You need to do that manually or add a line to your /etc/fstab This does not automaticly mount your USB drive at boot. You need to do that manually or add a line to your `/etc/fstab` file.
If your drive is on /dev/sda1, you could add a entry to your /etc/fstab like so:
``` If your drive is on `/dev/sda1`, you could add a entry to your `/etc/fstab` like so:
```text
/dev/sda1 /media ext4 defaults,noatime 0 1 /dev/sda1 /media ext4 defaults,noatime 0 1
``` ```
Manual: 'mount /dev/sda1 /media' Manual step to mount the USB drive:
```bash
# mount /dev/sda1 /media
```

View File

@ -203,6 +203,7 @@
<ul> <ul>
<li>{% active_link /docs/ecosystem/backup/backup_github/ Backup to GitHub %}</li> <li>{% active_link /docs/ecosystem/backup/backup_github/ Backup to GitHub %}</li>
<li>{% active_link /docs/ecosystem/backup/backup_dropbox/ Backup to Dropbox %}</li> <li>{% active_link /docs/ecosystem/backup/backup_dropbox/ Backup to Dropbox %}</li>
<li>{% active_link /docs/ecosystem/backup/backup_usb/ Backup to USB device %}</li>
</ul> </ul>
</li> </li>
<li>{% active_link /docs/ecosystem/scenegen/ scenegen %}</li> <li>{% active_link /docs/ecosystem/scenegen/ scenegen %}</li>