Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
Added possibilty to contain backup in a password-protected zip.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolai Bjerre Pedersen committed Mar 8, 2018
1 parent 186d061 commit cf9bda9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 12 deletions.
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog][keep-a-changelog] this project adheres to [Semantic Versioning][semantic-versioning].

## [1.0.0] - 2018-03-05
## [v0.2.0] (2018-03-07)

[Full Changelog][v0.1.0-v0.2.0]

### Added

- Possibilty to contain the backup in a password protected zip file.

## [v0.1.0] (2018-03-06)

### Added

- Initial release

[keep-a-changelog]: http://keepachangelog.com/en/1.0.0/
[semantic-versioning]: http://semver.org/spec/v2.0.0.html
[v0.1.0-v0.2.0]: https://github.com/mr-bjerre/hassio-remote-backup/compare/v0.1.0...v0.2.0
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ See my [repository of addons][hassio-addons] for more information.
|`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|

## <a name='example'></a>Example: daily backups at 4 AM

Expand Down Expand Up @@ -77,7 +78,8 @@ _Add-on configuration_:
"X+6r/gTvUEQv1ufAuUE5wKcq9FsbnTa3FOF0PdQDWl0=",
"-----END RSA PRIVATE KEY-----"
],
"remote_directory": "~/hassio-backups"
"remote_directory": "~/hassio-backups",
"zip_password": "password_protect_it"
}
```

Expand Down
2 changes: 1 addition & 1 deletion remote-backup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM $BUILD_FROM
ENV LANG C.UTF-8

# Setup base
RUN apk add --no-cache jq openssh-client
RUN apk add --no-cache jq openssh-client zip

# Hass.io CLI
ARG BUILD_ARCH
Expand Down
9 changes: 5 additions & 4 deletions remote-backup/config.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"name": "Remote Backup",
"version": "0.1.0",
"version": "dev",
"slug": "remote_backup",
"description": "Exploit snapshots and SCP to create remote backups to specified server",
"url": "https://github.com/mr-bjerre/hassio-remote-backup",
"startup": "once",
"boot": "manual",
"hassio_api": true,
"map": ["backup:rw"],
"image": "fixated/remote-backup-{arch}",
"options": {
"ssh_host": "",
"ssh_port": 22,
"ssh_user": "",
"ssh_key": [],
"remote_directory": ""
"remote_directory": "",
"zip_password": ""
},
"schema": {
"ssh_host": "str",
"ssh_port": "int",
"ssh_user": "str",
"ssh_key": ["str"],
"remote_directory": "str"
"remote_directory": "str",
"zip_password": "str"
}
}
15 changes: 12 additions & 3 deletions remote-backup/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SSH_PORT=$(jq --raw-output ".ssh_port" $CONFIG_PATH)
SSH_USER=$(jq --raw-output ".ssh_user" $CONFIG_PATH)
SSH_KEY=$(jq --raw-output ".ssh_key[]" $CONFIG_PATH)
REMOTE_DIRECTORY=$(jq --raw-output ".remote_directory" $CONFIG_PATH)
REPEAT=$(jq --raw-output '.repeat' $CONFIG_PATH)
ZIP_PASSWORD=$(jq --raw-output '.zip_password' $CONFIG_PATH)

# create variables
SSH_ID="${HOME}/.ssh/id"
Expand All @@ -34,8 +34,17 @@ function add-ssh-key {
}

function copy-backup-to-remote {
echo "Copying ${slug} to ${REMOTE_DIRECTORY} on ${SSH_HOST} using SCP"
scp -F "${HOME}/.ssh/config" "/backup/${slug}.tar" remote:"${REMOTE_DIRECTORY}"

cd /backup/
if [ "$ZIP_PASSWORD" == "" ]; then
echo "Copying ${slug}.tar to ${REMOTE_DIRECTORY} on ${SSH_HOST} using SCP"
scp -F "${HOME}/.ssh/config" "${slug}.tar" remote:"${REMOTE_DIRECTORY}"
else
echo "Copying password-protected ${slug}.zip to ${REMOTE_DIRECTORY} on ${SSH_HOST} using SCP"
zip -P "$ZIP_PASSWORD" "${slug}.zip" "${slug}".tar
scp -F "${HOME}/.ssh/config" "${slug}.zip" remote:"${REMOTE_DIRECTORY}" && rm "${slug}.zip"
fi

}

function delete-local-backup {
Expand Down

0 comments on commit cf9bda9

Please sign in to comment.