diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ef2ec..a8c1bd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 \ No newline at end of file +## [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 diff --git a/README.md b/README.md index fa5843f..607d7a4 100644 --- a/README.md +++ b/README.md @@ -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| ## Example: daily backups at 4 AM @@ -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" } ``` diff --git a/remote-backup/Dockerfile b/remote-backup/Dockerfile index 9a1ff96..dd62e46 100644 --- a/remote-backup/Dockerfile +++ b/remote-backup/Dockerfile @@ -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 diff --git a/remote-backup/config.json b/remote-backup/config.json index 47b711a..7c80f8a 100644 --- a/remote-backup/config.json +++ b/remote-backup/config.json @@ -1,6 +1,6 @@ { "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", @@ -8,19 +8,20 @@ "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" } } diff --git a/remote-backup/run.sh b/remote-backup/run.sh index baf7f16..54f53a3 100755 --- a/remote-backup/run.sh +++ b/remote-backup/run.sh @@ -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" @@ -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 {