Automatically create Hass.io snapshots to remote server location using
SCP
.
Note: For anyone using this as a local addon, it appears that the latest base image now requires updating to the new "OPENSSH" private key format. If you were previously using a private key that started "RSA PRIVATE KEY", you'll need to follow the instructions here to update your private key and add the new key in the addon config. Using the older key format will result in "Load pubkey "xxx": Invalid format" as described at the link.
When the add-on is started the following happens:
- Snapshot are being created locally with a timestamp name, e.g. Automatic backup 2018-03-04 04:00.
- The snapshot are copied to the specified remote location using
SCP
. - The local backup are removed locally again.
Note the filenames of the backup are given by their assigned slug.
- Add the add-ons repository to your Hass.io instance:
https://github.com/rccoleman/hassio-remote-backup
. - Install the Remote Backup add-on.
- Configure the add-on with your SSH credentials and desired output directory (see configuration below).
See my repository of addons for more information.
Parameter | Required | Description |
---|---|---|
ssh_host |
Yes | The hostname/url to the remote server. |
ssh_port |
Yes | The port to use to SCP on to the server. |
ssh_user |
Yes | Username to use for SCP . |
ssh_key |
Yes | The ssh key to use. Not that it should NOT be password protected. |
remote_directory |
Yes | The directory to put the backups on the remote server. |
zip_password |
No | If set then the backup will be contained in a password protected zip |
keep_local_backup |
No | Control how many local backups you want to preserve. Default ("" ) is to keep no local backups created from this addon. If all then all loocal backups will be preserved. A positive integer will determine how many of the latest backups will be preserved. Note this will delete other local backups created outside this addon. |
Personally I've added the following automation to make a daily backup. It is password-protected and the last two weeks of snapshots are kept locally as well.
configuration.yaml
automations:
- alias: Daily Backup at 4 AM
trigger:
platform: time
at: '4:00:00'
action:
- service: hassio.addon_start
data:
addon: ce20243c_remote_backup
Add-on configuration:
{
"ssh_host": "192.168.1.2",
"ssh_port": 22,
"ssh_user": "root",
"ssh_key": [
"-----BEGIN RSA PRIVATE KEY-----",
"MIICXAIBAAKBgQDTkdD4ya/Qxz5xKaKojVIOVWjyeyEoEuAafAvYvppqmaBhyh4N",
"5av4i87y8tdGusdq7V0Zj0+js4jEdvJRDrXJBrp1neLfsjkF6t1XLfrA51Ll9SXF",
"...",
"X+6r/gTvUEQv1ufAuUE5wKcq9FsbnTa3FOF0PdQDWl0=",
"-----END RSA PRIVATE KEY-----"
],
"remote_directory": "~/hassio-backups",
"zip_password": "password_protect_it",
"keep_local_backup": "14"
}
Note: This is just an example, don't copy and past it! Create your own!
This repository keeps a change log. The format of the log is based on Keep a Changelog.
Releases are based on Semantic Versioning, and use the format
of MAJOR.MINOR.PATCH
. In a nutshell, the version will be incremented
based on the following:
MAJOR
: Incompatible or major changes.MINOR
: Backwards-compatible new features and enhancements.PATCH
: Backwards-compatible bugfixes and package updates.