Skip to content

Commit

Permalink
implement overkill32#12
Browse files Browse the repository at this point in the history
  • Loading branch information
aschamberger authored Jul 29, 2019
1 parent 5186f54 commit 263d814
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions remote-backup/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,8 @@ function add-ssh-key {
function copy-backup-to-remote {

cd /backup/
if [[ -z $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

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

function delete-local-backup {
Expand Down Expand Up @@ -76,7 +69,11 @@ function delete-local-backup {
function create-local-backup {
name="Automated backup $(date +'%Y-%m-%d %H:%M')"
echo "Creating local backup: \"${name}\""
slug=$(hassio snapshots new --name="${name}" | jq --raw-output '.data.slug')
if [[ -z $ZIP_PASSWORD ]]; then
slug=$(hassio snapshots new --name="${name}" | jq --raw-output '.data.slug')
else
slug=$(hassio snapshots new --name="${name}" --password="${ZIP_PASSWORD}" | jq --raw-output '.data.slug')
fi
echo "Backup created: ${slug}"
}

Expand Down

0 comments on commit 263d814

Please sign in to comment.