diff --git a/README.md b/README.md index 5ee3b52..ddc670d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,18 @@ -# restic for Yunohost +# Restic for YunoHost [![Latest Version](https://img.shields.io/badge/version-0.9.6-green.svg?style=flat)](https://github.com/YunoHost-Apps/restic_ynh/releases) [![Status](https://img.shields.io/badge/status-testing-yellow.svg?style=flat)](https://github.com/YunoHost-Apps/restic_ynh/milestones) [![Integration level](https://dash.yunohost.org/integration/restic.svg)](https://dash.yunohost.org/appci/app/restic) [![GitHub license](https://img.shields.io/badge/license-GPLv3-blue.svg?style=flat)](https://raw.githubusercontent.com/YunoHost-Apps/restic_ynh/master/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/YunoHost-Apps/restic_ynh.svg?style=flat)](https://github.com/YunoHost-Apps/restic_ynh/issues) - [![Install restic with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=restic) -A [restic](https://restic.net/) package for YunoHost (heavily inspired by [the Borg package](https://github.com/YunoHost-Apps/borg_ynh/)). +> *This package allows you to install Restic quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* + +## Overview + +A [Restic](https://restic.net/) package for YunoHost (heavily inspired by [the Borg package](https://github.com/YunoHost-Apps/borg_ynh/)). Restic is a backup tool that can make local and remote backups. This package uses restic to make backups to a sftp server. @@ -17,7 +21,7 @@ This package uses restic to make backups to a sftp server. If you want to backup your server A onto the server B. -## Setup restic app on Server A +## Setup Restic app on Server A Firstly set up this app on the server A you want to backup: @@ -114,7 +118,7 @@ If you want to check the backups consistency: systemctl start restic_check.service ``` -If you want to make a complete check of the backups - keep in mind that this reads all the backed up data, it can take some time depending on your target server upload speed (more on this topic in [the restic documentation](https://restic.readthedocs.io/en/latest/045_working_with_repos.html#checking-integrity-and-consistency): +If you want to make a complete check of the backups - keep in mind that this reads all the backed up data, it can take some time depending on your target server upload speed (more on this topic in [the Restic documentation](https://restic.readthedocs.io/en/latest/045_working_with_repos.html#checking-integrity-and-consistency): ``` systemctl start restic_check_read_data.service ``` @@ -127,4 +131,31 @@ yunohost app setting restic apps -v "nextcloud,wordpress" ## Backup on different server, and apply distinct schedule for apps -You can setup the restic app several times on the same server so you can backup on several server or manage your frequency backup differently for specific part of your server. +You can setup the Restic app several times on the same server so you can backup on several server or manage your frequency backup differently for specific part of your server. + +#### Supported architectures + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/restic%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/restic/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/restic%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/restic/) + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/restic_ynh/issues + * App website: https://restic.net/ + * Upstream app repository: https://github.com/restic/restic + * YunoHost website: https://yunohost.org/ + +--- + +Developer info +---------------- + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/restic_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/restic_ynh/tree/testing --debug +or +sudo yunohost app upgrade restic -u https://github.com/YunoHost-Apps/restic_ynh/tree/testing --debug +``` + diff --git a/conf/backup_method.j2 b/conf/backup_method.j2 index ca7048a..71d9521 100644 --- a/conf/backup_method.j2 +++ b/conf/backup_method.j2 @@ -2,8 +2,16 @@ set -e -RESTIC_PASSWORD="{{ passphrase }}" -RESTIC_REPOSITORY_BASE=sftp:{{ server }}:{{ backup_path }} +### +# Fetch information from YNH settings +### +RESTIC_SERVER=$(yunohost app setting restic server) +RESTIC_SERVER_PORT=$(yunohost app setting restic port) +RESTIC_PATH=$(yunohost app setting restic backup_path) + +RESTIC_PASSWORD="$(yunohost app setting restic passphrase)" +RESTIC_REPOSITORY_BASE=sftp://$RESTIC_SERVER:$RESTIC_SERVER_PORT/$RESTIC_PATH/ + RESTIC_COMMAND=/usr/local/bin/restic LOGFILE=/var/log/restic_backup.log ERRFILE=/var/log/restic_backup.err diff --git a/conf/check-restic.j2 b/conf/check-restic.j2 index 2c6dd8c..a9d404f 100644 --- a/conf/check-restic.j2 +++ b/conf/check-restic.j2 @@ -31,7 +31,7 @@ fi # Check all apps independently apps=$(yunohost app setting {{ app }} apps) -for app in $(yunohost app list --installed -b | grep id: | cut -d: -f2); do +for app in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do check_app=false for selected_app in $(echo $apps | tr "," " ");do if [[ "$selected_app" == "$app" ]] || [ "$apps" = "all" ]; then diff --git a/conf/check_method.j2 b/conf/check_method.j2 index 9ce03fc..9884daa 100644 --- a/conf/check_method.j2 +++ b/conf/check_method.j2 @@ -2,8 +2,13 @@ set -e -RESTIC_PASSWORD="{{ passphrase }}" -RESTIC_REPOSITORY_BASE=sftp:{{ server }}:{{ backup_path }} +RESTIC_SERVER=$(yunohost app setting restic server) +RESTIC_SERVER_PORT=$(yunohost app setting restic port) +RESTIC_PATH=$(yunohost app setting restic backup_path) + +RESTIC_PASSWORD="$(yunohost app setting restic passphrase)" +RESTIC_REPOSITORY_BASE=sftp://$RESTIC_SERVER:$RESTIC_SERVER_PORT/$RESTIC_PATH/ + RESTIC_COMMAND=/usr/local/bin/restic do_check() { diff --git a/manifest.json b/manifest.json index 47dd5bf..b2538b5 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Backup your server with restic.", "fr": "Sauvegardez votre serveur avec restic." }, - "version": "0.9.6~ynh6", + "version": "0.10.0~ynh1", "url": "https://restic.net/", "license": "BSD 2-Clause \"Simplified\" License", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index dd1705a..7851aa9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # App package root directory should be the parent folder PKG_DIR=$(cd ../; pwd) -RESTIC_VERSION="0.9.6" +RESTIC_VERSION="0.10.0" # Install restic if restic is not here install_restic () { @@ -57,7 +57,7 @@ ynh_export () { export $var="${!ynh_arg}" done } -# Save listed var in YunoHost app settings +# Save listed var in YunoHost app settings # usage: ynh_save_args VARNAME1 [VARNAME2 [...]] ynh_save_args () { for var in $@; diff --git a/scripts/install b/scripts/install index 15f9f7e..66ef0d9 100755 --- a/scripts/install +++ b/scripts/install @@ -65,6 +65,9 @@ ynh_add_systemd_config --service=${app}_check_read_data --template=systemd_check ynh_configure systemd.timer "/etc/systemd/system/${app}.timer" ynh_configure systemd_check.timer "/etc/systemd/system/${app}_check.timer" ynh_configure systemd_check_read_data.timer "/etc/systemd/system/${app}_check_read_data.timer" +systemctl disable ${app}.service +systemctl disable ${app}_check.service +systemctl disable ${app}_check_read_data.service systemctl enable ${app}.timer systemctl enable ${app}_check.timer systemctl enable ${app}_check_read_data.timer diff --git a/scripts/restore b/scripts/restore index c55046d..c76eaf5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -38,7 +38,7 @@ mkdir -p /usr/share/yunohost/backup_method #================================================= # RESTORE FILES #================================================= -ynh_restore +ynh_restore #================================================= # ADVERTISE SERVICE IN ADMIN PANEL