diff --git a/CHANGELOG.md b/CHANGELOG.md index 31a7558..100a247 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/templates/restic_access_Linux.j2 b/templates/restic_access_Linux.j2 index 8c52cdc..f9b62dd 100644 --- a/templates/restic_access_Linux.j2 +++ b/templates/restic_access_Linux.j2 @@ -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 }} diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index 8374200..5f90e10 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -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 }}