Commit 0f61b751 authored by Jocelyn Delalande's avatar Jocelyn Delalande

Use absolute path for borg binary

One of the reasons why is that the PATH of cron jobs seems not to find our
binary in /usr/local/bin.
parent 39cd4cc6
......@@ -3,6 +3,7 @@ borg_ynh_backup_home: "/home/{{ borg_ynh_backup_user }}"
borg_ynh_backup_ssh_key: "{{ borg_ynh_backup_home }}/.ssh/id_rsa"
borg_ynh_backup_log_path: /var/log/borg-ynh-backup.log
borg_ynh_backup_tmp_path: /home/yunohost.backup/borg-tmp/
borg_ynh_backup_borg_path: /usr/local/bin/borg
borg_ynh_backup_bin_path: "{{ borg_ynh_backup_home }}/bin"
borg_ynh_backup_sudoed_create: "{{ borg_ynh_backup_bin_path }}/ynh-backup-create"
......
- name: Check that borg is installed (see borg-common role)
file: path=/usr/local/bin/borg state=file follow=yes
file: path={{ borg_ynh_borg_path }} state=file follow=yes
- name: Create dedicated user
user:
......
......@@ -13,7 +13,7 @@ export BORG_PASSPHRASE="notsosecret"
export BORG_KEYS_DIR="{{ borg_ynh_backup_home }}/.borg/keys"
export BORG_CACHE_DIR="{{ borg_ynh_backup_home }}/.borg/cache"
borg create -v --stats "${ARCHIVE}" ${TMP_PATH}
{{ borg_ynh_backup_borg_path }} create -v --stats "${ARCHIVE}" ${TMP_PATH}
# Give back the backup cache to the dedicated user
chown -R {{ borg_ynh_backup_user }}:{{ borg_ynh_backup_user }} \
......
......@@ -19,6 +19,7 @@ export BORG_CACHE_DIR="{{ borg_ynh_backup_home }}/.borg/cache"
YNH_BACKUP_CREATE={{ borg_ynh_backup_sudoed_create }}
BORG_BACKUP_PUSH={{ borg_ynh_backup_sudoed_push }}
YNH_BACKUP_CLEANUP={{ borg_ynh_backup_sudoed_cleanup }}
BORG={{ borg_ynh_backup_borg_path }}
# Trap on non-zero exit
trap '[ "$?" -eq 0 ] || cleanup' EXIT
......@@ -42,14 +43,14 @@ ts_log "Performing yunohost backup."
sudo -n $YNH_BACKUP_CREATE $BACKUP_DATE >> ${LOG_PATH} 2>&1
ts_log "Initializing repository, if needed."
borg list ${REPOSITORY} >/dev/null 2>&1 || \
borg init --encryption=keyfile ${REPOSITORY} >> ${LOG_PATH} 2>&1
$BORG list ${REPOSITORY} >/dev/null 2>&1 || \
$BORG init --encryption=keyfile ${REPOSITORY} >> ${LOG_PATH} 2>&1
ts_log "Creating archive ${ARCHIVE}."
sudo -n $BORG_BACKUP_PUSH $BACKUP_DATE >> ${LOG_PATH} 2>&1
ts_log "Rotating old backups."
borg prune -v $REPOSITORY \
$BORG prune -v $REPOSITORY \
--keep-daily={{ borg_ynh_backup_daily }} \
--keep-weekly={{ borg_ynh_backup_weekly }} \
--keep-monthly={{ borg_ynh_backup_monthly }} \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment