Skip to content

Commit

Permalink
Merge pull request #10 from arillso/use-regex-escape
Browse files Browse the repository at this point in the history
Escape Restic Password correctly
  • Loading branch information
mleutenegger authored Jun 4, 2020
2 parents d3d0336 + 9bc6c06 commit 700853b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
and [human-readable changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
### Changed
* Password now use `regex_escape()` filter in templates

## [0.2.5] - 2020-06-02
### Fixed:
* AWS credentials are now supplied to the initialising step
Expand Down
4 changes: 2 additions & 2 deletions templates/restic_access_Linux.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# Source this file to work with restic on this host

export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }}
export RESTIC_PASSWORD={{ restic_repos[item.repo].password }}
export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'', '\'\\\'\'') }}'
{% if restic_repos[item.repo].aws_access_key is defined %}
export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }}
{% endif %}
{% if restic_repos[item.repo].aws_secret_access_key is defined %}
export AWS_SECRET_ACCESS_KEY={{ restic_repos[item.repo].aws_secret_access_key }}
export AWS_SECRET_ACCESS_KEY='{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}'
{% endif %}
{% if restic_repos[item.repo].aws_default_region is defined %}
export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }}
Expand Down
4 changes: 2 additions & 2 deletions templates/restic_script_Linux.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# Use this file to create a Backup and prune existing data with one execution.

export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }}
export RESTIC_PASSWORD={{ restic_repos[item.repo].password }}
export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'', '\'\\\'\'') }}'
BACKUP_NAME={{ item.name }}
{% if restic_repos[item.repo].aws_access_key is defined %}
export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }}
{% endif %}
{% if restic_repos[item.repo].aws_secret_access_key is defined %}
export AWS_SECRET_ACCESS_KEY={{ restic_repos[item.repo].aws_secret_access_key }}
export AWS_SECRET_ACCESS_KEY='{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}'
{% endif %}
{% if restic_repos[item.repo].aws_default_region is defined %}
export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }}
Expand Down

0 comments on commit 700853b

Please sign in to comment.