From f78d1d83f7b6f586f73c4a9027ec05aafe667c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 6 Jan 2024 12:07:10 +0100 Subject: [PATCH 01/35] Manifest v2 --- check_process | 50 ------------------- doc/POST_INSTALL.md | 10 ++++ manifest.json | 104 --------------------------------------- manifest.toml | 96 ++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 117 +++++++++----------------------------------- scripts/backup | 20 ++------ scripts/install | 111 ++++++++++------------------------------- scripts/remove | 26 +++------- scripts/restore | 65 +++++++++--------------- scripts/upgrade | 111 ++++++++++++----------------------------- tests.toml | 38 ++++++++++++++ 11 files changed, 257 insertions(+), 491 deletions(-) delete mode 100644 check_process create mode 100644 doc/POST_INSTALL.md delete mode 100644 manifest.json create mode 100644 manifest.toml create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 87f3827..0000000 --- a/check_process +++ /dev/null @@ -1,50 +0,0 @@ -;; Test remote directory - ; Manifest - repository="ssh://sam@domain.tld:22/~/backup" - passphrase="APassphrase" - conf=1 - data=1 - apps="all" - on_calendar="Daily" - mailalert="errors_only" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - upgrade=1 from_commit=d1cd666ee27f5cfb8e40c6f44a09370381b41b35 - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=0 -;; Test local directory - ; Manifest - repository="/mnt/backup" - passphrase="APassphrase" - conf=1 - data=1 - apps="all" - on_calendar="Daily" - mailalert="errors_only" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=0 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=d1cd666ee27f5cfb8e40c6f44a09370381b41b35 - name=Older ynh 11 version - manifest_arg=server=domain.tld:22&ssh_user=package_checker&passphrase=APassphrase&conf=1&data=1&apps=all&on_calendar=Daily&mailalert=never diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..a1e6b24 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,10 @@ +If you selected a remote borg server as backup target, you should now install the "Borg Server" app on __SERVER__ and with the following credentials: + +User: __SSH_USER__ +Public key: __PUBLIC_KEY__ + +Or if you want to use cli: + +`yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh -a "ssh_user=__SSH_USER__&public_key=__PUBLIC_KEY__"` + +If you facing an issue or want to improve this app, please open a new issue in this project: diff --git a/manifest.json b/manifest.json deleted file mode 100644 index c653bca..0000000 --- a/manifest.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "name": "Borg Backup", - "id": "borg", - "packaging_format": 1, - "description": { - "en": "Backup your server on a host server using Borg", - "fr": "Sauvegardez votre serveur sur un serveur distant avec Borg" - }, - "version": "1.1.16~ynh30", - "url": "https://borgbackup.readthedocs.io", - "upstream": { - "license": "BSD-3-Clause", - "website": "https://borgbackup.readthedocs.io" - }, - "license": "BSD-3-Clause", - "maintainer": { - "name": "ljf", - "email": "ljf+borg_ynh@reflexlibre.net", - "url": "https://reflexlibre.net" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [], - "arguments": { - "install" : [ - { - "name": "repository", - "type": "string", - "ask": { - "en": "In which borg repository location do you want to backup your files ?", - "fr": "Dans quel repo borg souhaitez-vous sauvegarder vos fichiers ?" - }, - "help":{ - "en": "Specify a local repository like /mount/my_external_harddrive/backups or a remote repository using this format: ssh://USER@DOMAIN.TLD:PORT/~/backup . If you plan to use borgserver_ynh app : 'USER' is *not* meant to be an existing user on the guest server, instead, it will be created *on the host server* during the installation of the Borg Server App. With borgserver_ynh apps you can't specify another repo path than ~/backup." - }, - "example": "ssh://john@serverb.tld:22/~/backup" - }, - { - "name": "passphrase", - "type": "password", - "ask": { - "en": "Provide a strong passphrase to encrypt your backups. No blank space", - "fr": "Indiquez une phrase de passe forte pour chiffrer vos sauvegardes. Sans espaces" - }, - "help":{ - "en": "Keep it safe! ...if you want to be able to restore. Do not communicate it to host Server holder or anyone else.", - "fr": "Gardez-la précieusement! ...si vous voulez pouvoir restaurer. Ne donnez pas la clé au possesseur du Serveur distant, ni personne." - } - }, - { - "name": "conf", - "type": "boolean", - "ask": { - "en": "Should Borg backup your YunoHost configuration?", - "fr": "Borg doit-il sauvegarder la configuration système YunoHost ?" - }, - "default": true - }, - { - "name": "data", - "type": "boolean", - "ask": { - "en": "Should Borg backup emails and user home directory?", - "fr": "Borg doit-il sauvegarder les mails et les répertoires des utilisateurs ?" - }, - "default": true - }, - { - "name": "apps", - "type": "string", - "ask": { - "en": "Which apps should Borg backup ?", - "fr": "Quelles applications doivent être sauvegardées par Borg ?" - }, - "help":{ - "en": "App list separated by comma. You can write 'all' to select all apps, even those installed after this borg app. You can also select all apps but some apps by writing 'exclude:' following by an app list separated by comma.", - "fr": "Liste d'applications séparées par des virgules. Vous pouvez écrire 'all' pour sélectionner toutes les apps, même celles installées après cette application borg. Vous pouvez aussi sélectionner toutes les apps sauf certaines en écrivant 'exclude:' suivi d'une liste d'applications séparées par des virgules." - }, - "default": "all" - }, - { - "name": "on_calendar", - "type": "string", - "ask": { - "en": "With which regular time schedule should the backups be performed? (see systemd OnCalendar format)", - "fr": "À quelle fréquence les sauvegardes doivent-elles être effectuées ? (voir le format OnCalendar de systemd)" - }, - "example": "Monthly or Weekly or Daily or Hourly or 4:00 or 5,17:00 or Sat --1..7 18:00:00", - "default": "Daily" - }, - { - "name": "mailalert", - "type": "select", - "ask": { - "en": "Do you want admin to receive mail notifications on backups ?", - "fr": "Souhaitez-vous recevoir des notifications par mail à chaque sauvegarde ?" - }, - "choices": ["always", "errors_only", "never"] - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..41fdfda --- /dev/null +++ b/manifest.toml @@ -0,0 +1,96 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "borg" +name = "Borg Backup" +description.en = "Backup your server on a host server using Borg" +description.fr = "Sauvegardez votre serveur sur un serveur distant avec Borg" + +version = "1.1.16~ynh30" + +maintainers = ["ljf"] + +[upstream] +license = "BSD-3-Clause" +website = "https://borgbackup.readthedocs.io" +cpe = "cpe:2.3:a:borg_project:borg" +fund = "https://www.borgbackup.org/support/fund.html" + +[integration] +yunohost = ">= 11.0.9" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "not_relevant" +sso = "not_relevant" +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.repository] + ask.en = "In which borg repository location do you want to backup your files ?" + ask.fr = "Dans quel repo borg souhaitez-vous sauvegarder vos fichiers ?" + help.en = "Specify a local repository like /mount/my_external_harddrive/backups or a remote repository using this format: ssh://USER@DOMAIN.TLD:PORT/~/backup . If you plan to use borgserver_ynh app : 'USER' is *not* meant to be an existing user on the guest server, instead, it will be created *on the host server* during the installation of the Borg Server App. With borgserver_ynh apps you can't specify another repo path than ~/backup." + type = "string" + example = "ssh://john@serverb.tld:22/~/backup" + + [install.passphrase] + ask.en = "Provide a strong passphrase to encrypt your backups. No blank space" + ask.fr = "Indiquez une phrase de passe forte pour chiffrer vos sauvegardes. Sans espaces" + help.en = "Keep it safe! ...if you want to be able to restore. Do not communicate it to host Server holder or anyone else." + help.fr = "Gardez-la précieusement! ...si vous voulez pouvoir restaurer. Ne donnez pas la clé au possesseur du Serveur distant, ni personne." + type = "password" + + [install.conf] + ask.en = "Should Borg backup your YunoHost configuration?" + ask.fr = "Borg doit-il sauvegarder la configuration système YunoHost ?" + type = "boolean" + default = true + + [install.data] + ask.en = "Should Borg backup emails and user home directory?" + ask.fr = "Borg doit-il sauvegarder les mails et les répertoires des utilisateurs ?" + type = "boolean" + default = true + + [install.apps] + ask.en = "Which apps should Borg backup ?" + ask.fr = "Quelles applications doivent être sauvegardées par Borg ?" + help.en = "App list separated by comma. You can write 'all' to select all apps, even those installed after this borg app. You can also select all apps but some apps by writing 'exclude:' following by an app list separated by comma." + help.fr = "Liste d'applications séparées par des virgules. Vous pouvez écrire 'all' pour sélectionner toutes les apps, même celles installées après cette application borg. Vous pouvez aussi sélectionner toutes les apps sauf certaines en écrivant 'exclude:' suivi d'une liste d'applications séparées par des virgules." + type = "string" + default = "all" + + [install.on_calendar] + ask.en = "With which regular time schedule should the backups be performed? (see systemd OnCalendar format)" + ask.fr = "À quelle fréquence les sauvegardes doivent-elles être effectuées ? (voir le format OnCalendar de systemd)" + type = "string" + example = "Monthly or Weekly or Daily or Hourly or 4:00 or 5,17:00 or Sat --1..7 18:00:00" + default = "Daily" + + [install.mailalert] + ask.en = "Do you want admin to receive mail notifications on backups ?" + ask.fr = "Souhaitez-vous recevoir des notifications par mail à chaque sauvegarde ?" + type = "select" + choices = ["always", "errors_only", "never"] + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.apt] + packages = [ + "python3-pip", + "python3-dev", + "libacl1-dev", + "libssl-dev", + "liblz4-dev", + "python3-jinja2", + "python3-setuptools", + "python3-venv", + "virtualenv", + "libfuse-dev", + "pkg-config", + ] diff --git a/scripts/_common.sh b/scripts/_common.sh index 699abd3..af21316 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,11 +3,12 @@ #================================================= # COMMON VARIABLES #================================================= -# App package root directory should be the parent folder -PKG_DIR=$(cd ../; pwd) + BORG_VERSION=1.1.16 -pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev python3-jinja2 python3-setuptools python3-venv virtualenv libfuse-dev pkg-config" +#================================================= +# PERSONAL HELPERS +#================================================= # Install borg with pip if borg is not here install_borg_with_pip () { @@ -17,7 +18,7 @@ install_borg_with_pip () { if [ ! -d /opt/borg-env ]; then python3 -m venv /opt/borg-env /opt/borg-env/bin/python /opt/borg-env/bin/pip install pip -U - /opt/borg-env/bin/python /opt/borg-env/bin/pip install setuptools -U + /opt/borg-env/bin/python /opt/borg-env/bin/pip install setuptools -U /opt/borg-env/bin/python /opt/borg-env/bin/pip install wheel ynh_print_info --message="Installing/compiling borg, this may take some time..." /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[fuse]==$BORG_VERSION @@ -29,98 +30,24 @@ install_borg_with_pip () { chmod a+x /usr/local/bin/borg } -#================================================= -# COMMON HELPERS -#================================================= -ynh_export () { - local ynh_arg="" - for var in $@; - do - ynh_arg=$(echo $var | awk '{print toupper($0)}') - if [ "$var" == "path_url" ]; then - ynh_arg="PATH" +_gen_and_save_public_key() { + public_key="" + + if [[ -n "$server" ]]; then + private_key="/root/.ssh/id_${app}_ed25519" + if [ ! -f "$private_key" ]; then + ssh-keygen -q -t ed25519 -N "" -f "$private_key" fi - ynh_arg="YNH_APP_ARG_$ynh_arg" - export $var="${!ynh_arg}" - done -} -# Save listed var in YunoHost app settings -# usage: ynh_save_args VARNAME1 [VARNAME2 [...]] -ynh_save_args () { - for var in $@; - do - local setting_var="$var" - if [ "$var" == "path_url" ]; then - setting_var="path" - fi - ynh_app_setting_set $app $setting_var "${!var}" - done + public_key=$(cat "$private_key.pub") + fi + + ynh_app_setting_set --app="$app" --key=public_key --value="$public_key" } -# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args +#================================================= +# EXPERIMENTAL HELPERS +#================================================= -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: -m --app_message= - The message to send to the administrator. -# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: app_message - The message to send to the administrator. -# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -ynh_send_readme_to_admin() { - local app_message="${1:-...No specific information...}" - local recipients="${2:-root}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" - - local mail_message="This is an automated message from your beloved YunoHost server. -Specific information for the application $app. -$app_message ---- -Automatic diagnosis data from YunoHost -$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - # Send the email to the recipients - echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" -} +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index 7b3d35e..42fc15e 100755 --- a/scripts/backup +++ b/scripts/backup @@ -8,30 +8,18 @@ source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= ynh_print_info --message="Declaring files to be backed up..." -ynh_backup --src_path="/usr/local/bin/backup-with-$app" -ynh_backup --src_path="/etc/sudoers.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.timer" + ynh_backup --src_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app" +ynh_backup --src_path="/usr/local/bin/backup-with-$app" +ynh_backup --src_path="/etc/sudoers.d/$app" + ynh_backup --src_path="/root/.ssh/id_${app}_ed25519" --not_mandatory ynh_backup --src_path="/root/.ssh/id_${app}_ed25519.pub" --not_mandatory diff --git a/scripts/install b/scripts/install index e89ba36..b6231d6 100755 --- a/scripts/install +++ b/scripts/install @@ -9,72 +9,54 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -export app=$YNH_APP_INSTANCE_NAME -# Retrieve arguments -ynh_export repository passphrase on_calendar conf data apps mailalert - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -server="" -if [[ $repository == *"@"* ]]; then - server=$(echo "$repository" | cut -d"@" -f2 | cut -d"/" -f1) - if [[ $server == *":"* ]]; then - server="[$(echo "$server" | cut -d":" -f1)]:$(echo "$server" | cut -d":" -f2)" + +ssh_regex='^ssh://([^@]*)@([^:/]*)(:[0-9]+)?/(.*)$' +if [[ "$repository" =~ $ssh_regex ]]; then + ssh_user="${BASH_REMATCH[1]}" + server="${BASH_REMATCH[2]}" + port="${BASH_REMATCH[3]}" + if [[ -n "$port" ]]; then + server="[$server]$port" fi - ssh_user=$(echo "$repository" | cut -d"@" -f1 | cut -d"/" -f2) fi + +ynh_app_setting_set --app=$app --key=server --value="$server" + state="repository uncreated" +ynh_app_setting_set --app=$app --key=state --value="$state" last_run="-" -ynh_save_args repository server passphrase on_calendar conf data apps mailalert state last_run +ynh_app_setting_set --app=$app --key=last_run --value="$last_run" #================================================= -# INSTALL DEPENDENCIES +# INSTALL BORG #================================================= -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing Borg..." -ynh_install_app_dependencies $pkg_dependencies install_borg_with_pip -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +_gen_and_save_public_key -# Create a system user -ynh_system_user_create --username=$app +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" +chmod u+w "/var/log/$app" #================================================= # SPECIFIC SETUP #================================================= -# ACTIVATE BACKUP METHODS +# SETUP THE BACKUP METHOD #================================================= +ynh_script_progression --message="Setting up backup method..." --weight=1 mkdir -p /etc/yunohost/hooks.d/backup mkdir -p /etc/yunohost/hooks.d/backup_method mkdir -p /usr/share/yunohost/backup_method -mkdir -p /var/log/${app} -chown -R $app:$app /var/log/${app} -chmod u+w /var/log/${app} -#================================================= -# SETUP THE BACKUP METHOD -#================================================= ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app" chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app" - ynh_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app" chmod u+x "/usr/local/bin/backup-with-$app" chown $app:$app "/usr/local/bin/backup-with-$app" @@ -82,65 +64,22 @@ chown $app:$app "/usr/local/bin/backup-with-$app" ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app" chown root:root "/etc/sudoers.d/$app" -if [ ! -z "$server" ]; then - #================================================= - # GENERATE SSH KEY - #================================================= - - private_key="/root/.ssh/id_${app}_ed25519" - test -f $private_key || ssh-keygen -q -t ed25519 -N "" -f $private_key - - #================================================= - # Display key - #================================================= - - echo "You should now install the \"Borg Server\" app on $server and with the following credentials: - User: ${ssh_user} - Public key: $(cat ${private_key}.pub)" - - #================================================= - # SEND A README FOR THE ADMIN - #================================================= - - message="You should now install the \"Borg Server\" app on $server and with the following credentials: -User: ${ssh_user} -Public key: $(cat ${private_key}.pub) - -Or if you want to use cli: - -yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh -a \"ssh_user=${ssh_user}&public_key=$(cat ${private_key}.pub)\" - -If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/borg_ynh" - - ynh_send_readme_to_admin "$message" -fi - #================================================= -# SETUP SYSTEMD +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add $app --description="Deduplicating backup program" --test_status="systemctl show $app.service -p ActiveState --value | grep -v failed" # Disable the service, this is to prevent the service from being triggered at boot time systemctl disable $app.service --quiet -#================================================= -# CONFIGURE SYSTEMD TIMER -#================================================= +# Configure the systemd timer ynh_add_config --template="systemd.timer" --destination="/etc/systemd/system/$app.timer" systemctl enable $app.timer --quiet systemctl start $app.timer -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -# Inactive services are ignored cause it's a timer -yunohost service add $app --description="Deduplicating backup program" --test_status="systemctl show $app.service -p ActiveState --value | grep -v failed" - - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index e3da1d5..bcc3561 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,42 +9,32 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -app=$YNH_APP_INSTANCE_NAME - #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null -then - ynh_script_progression --message="Removing $app service integration..." - yunohost service remove $app +if ynh_exec_warn_less yunohost service status $app >/dev/null; then + ynh_script_progression --message="Removing $app service integration..." + yunohost service remove $app fi #================================================= -# REMOVE DEPENDENCIES +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing dependencies..." +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 -ynh_remove_app_dependencies - -#================================================= -# REMOVE FILES -#================================================= systemctl stop $app.timer systemctl disable $app.timer --quiet ynh_remove_systemd_config + ynh_secure_remove "/etc/systemd/system/$app.timer" ynh_secure_remove "/usr/local/bin/backup-with-$app" ynh_secure_remove "/etc/yunohost/hooks.d/backup_method/05-${app}_app" # Remove borg if we are removing the last borg app on the system -if [ "$(yunohost app list | grep "id: borg" | wc -l)" == "1" ] ; then +if [ "$(yunohost app list | grep "id: borg" | wc -l)" == "1" ] ; then + ynh_script_progression --message="Removing borg..." --weight=1 ynh_secure_remove "/opt/borg-env" ynh_secure_remove "/usr/local/bin/borg" fi diff --git a/scripts/restore b/scripts/restore index 2f93f48..0a41509 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,70 +10,51 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# INSTALL BORG #================================================= +ynh_script_progression --message="Reinstalling Borg..." -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." - -ynh_install_app_dependencies $pkg_dependencies install_borg_with_pip -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +_gen_and_save_public_key -# Create a system user -ynh_system_user_create --username=$app +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" +chmod u+w "/var/log/$app" #================================================= # ACTIVATE BACKUP METHODS #================================================= +ynh_script_progression --message="Setting up backup method..." --weight=1 +mkdir -p /etc/yunohost/hooks.d/backup mkdir -p /etc/yunohost/hooks.d/backup_method mkdir -p /usr/share/yunohost/backup_method -mkdir -p /etc/yunohost/hooks.d/backup -mkdir -p /var/log/${app} -chown -R $app:$app /var/log/${app} -chmod u+w /var/log/${app} -#================================================= -# RESTORE FILES -#================================================= - -ynh_restore +ynh_restore_file --origin_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app" chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app" + +ynh_restore_file --origin_path="/usr/local/bin/backup-with-$app" chmod u+x "/usr/local/bin/backup-with-$app" chown $app:$app "/usr/local/bin/backup-with-$app" +ynh_restore_file --origin_path="/etc/sudoers.d/$app" +chown root:root "/etc/sudoers.d/$app" + #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# RESTORE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +yunohost service add $app --description="Deduplicating backup program" --test_status="systemctl show $app.service -p ActiveState --value | grep -v failed" +# Disable the service, this is to prevent the service from being triggered at boot time +systemctl disable $app.service --quiet + +ynh_restore_file --origin_path="/etc/systemd/system/$app.timer" systemctl enable $app.timer --quiet systemctl start $app.timer -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -# Inactive services are ignored cause it's a timer -yunohost service add $app --description="Deduplicating backup program" --test_status="systemctl show $app.service -p ActiveState --value | grep -v failed" - - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5d7c41c..53d5393 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,52 +9,30 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -export app=$YNH_APP_INSTANCE_NAME - -export repository="$(ynh_app_setting_get $app repository)" -export server="$(ynh_app_setting_get $app server)" -export ssh_user="$(ynh_app_setting_get $app ssh_user)" -export passphrase="$(ynh_app_setting_get $app passphrase)" -export on_calendar="$(ynh_app_setting_get $app on_calendar)" -export conf="$(ynh_app_setting_get $app conf)" -export data="$(ynh_app_setting_get $app data)" -export apps="$(ynh_app_setting_get $app apps)" -export mailalert="$(ynh_app_setting_get $app mailalert)" -if [[ $mailalert != "always" && $mailalert != "errors_only" && $mailalert != "never" ]]; then - ynh_app_setting_set --app=$app --key="mailalert" --value="errors_only" - export mailalert="errors_only" -fi -ynh_app_setting_set --app=$app --key="state" --value="not run since last update" -ynh_app_setting_set --app=$app --key="last_run" --value="-" +upgrade_type=$(ynh_check_app_version_changed) #================================================= -# CHECK IF AN UPGRADE IS NEEDED +# STANDARD UPGRADE STEPS #================================================= -ynh_check_app_version_changed - +# STOP SYSTEMD SERVICE #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Stopping a systemd service..." --weight=1 -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app.timer --action="stop" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +if [[ "${mailalert:-}" != "always" && "${mailalert:-}" != "errors_only" && "${mailalert:-}" != "never" ]]; then + ynh_app_setting_set --app=$app --key="mailalert" --value="errors_only" + export mailalert="errors_only" +fi +ynh_app_setting_set --app=$app --key="state" --value="not run since last update" +ynh_app_setting_set --app=$app --key="last_run" --value="-" + if [ -z "$repository" ]; then repository="ssh://$ssh_user@$server/~/backup" @@ -82,34 +60,27 @@ if [ ! -f "/opt/borg-env/$(ynh_get_debian_release)" ] ; then fi #================================================= -# UPGRADE DEPENDENCIES +# UPGRADE BORG #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app - - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# Upgrade borgbackup -#================================================= -ynh_script_progression --message="Upgrading borgbackup..." --weight=1 +ynh_script_progression --message="Upgrading Borg..." --weight=1 install_borg_with_pip +_gen_and_save_public_key + +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" +chmod u+w "/var/log/$app" + #================================================= # SETUP THE BACKUP METHOD #================================================= ynh_script_progression --message="Setting up backup method..." --weight=1 + +mkdir -p /etc/yunohost/hooks.d/backup +mkdir -p /etc/yunohost/hooks.d/backup_method +mkdir -p /usr/share/yunohost/backup_method + ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app" chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app" @@ -121,40 +92,20 @@ ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app" chown root:root "/etc/sudoers.d/$app" #================================================= -# SETUP SYSTEMD +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add $app --description="Deduplicating backup program" --test_status="systemctl show $app.service -p ActiveState --value | grep -v failed" # Disable the service, this is to prevent the service from being triggered at boot time systemctl disable $app.service --quiet -#================================================= -# CONFIGURE SYSTEMD TIMER -#================================================= ynh_add_config --template="systemd.timer" --destination="/etc/systemd/system/$app.timer" systemctl enable $app.timer --quiet systemctl start $app.timer -mkdir -p /etc/yunohost/hooks.d/backup -mkdir -p /var/log/${app} -chown -R $app:$app /var/log/${app} -chmod u+w /var/log/${app} - -#================================================= -# GENERIC FINALIZATION -#================================================= - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -# Inactive services are ignored cause it's a timer -yunohost service add $app --description="Deduplicating backup program" --test_status="systemctl show $app.service -p ActiveState --value | grep -v failed" - - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..050cb44 --- /dev/null +++ b/tests.toml @@ -0,0 +1,38 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + args.repository = "ssh://sam@domain.tld:22/~/backup" + args.passphrase = "A_Passphrase" + args.conf = 1 + args.data = 1 + args.apps = "all" + args.on_calendar = "Daily" + args.mailalert = "errors_only" + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + [default.test_upgrade_from.d1cd666ee27f5cfb8e40c6f44a09370381b41b35] + name = "Older ynh 11 version" + args.server = "domain.tld:22" + args.ssh_user = "package_checker" + args.passphrase = "A_Passphrase" + args.conf = 1 + args.data = 1 + args.apps = "all" + args.on_calendar = "Daily" + args.mailalert = "never" + + +[local_directory] + args.repository = "/mnt/backup" + args.passphrase = "A_Passphrase" + args.conf = 1 + args.data = 1 + args.apps = "all" + args.on_calendar = "Daily" + args.mailalert = "errors_only" From 771b215f4e17da8673c2b371c93217f975acb267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 6 Jan 2024 12:53:10 +0100 Subject: [PATCH 02/35] Add default value for arg --- manifest.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.toml b/manifest.toml index 41fdfda..ced07d3 100644 --- a/manifest.toml +++ b/manifest.toml @@ -74,6 +74,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen ask.fr = "Souhaitez-vous recevoir des notifications par mail à chaque sauvegarde ?" type = "select" choices = ["always", "errors_only", "never"] + default = "errors_only" [resources] [resources.system_user] From 297dd6903ba08961c3cced3b695caea678483f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 6 Jan 2024 13:00:11 +0100 Subject: [PATCH 03/35] Fix: save ssh_user --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index b6231d6..688cc6f 100755 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ if [[ "$repository" =~ $ssh_regex ]]; then fi fi +ynh_app_setting_set --app=$app --key=ssh_user --value="$ssh_user" ynh_app_setting_set --app=$app --key=server --value="$server" state="repository uncreated" From 46ad2ce2fbdb626fb4329dc9cf950cb8b040fdde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 6 Jan 2024 13:32:05 +0100 Subject: [PATCH 04/35] Refactor doc manifestv2 --- doc/{DISCLAIMER.md => ADMIN.md} | 65 +++++++++++++++++++++++---------- doc/DECSRIPTION.md | 4 +- doc/POST_INSTALL.md | 2 + 3 files changed, 50 insertions(+), 21 deletions(-) rename doc/{DISCLAIMER.md => ADMIN.md} (90%) diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 90% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md index 46a0cd9..cfec498 100644 --- a/doc/DISCLAIMER.md +++ b/doc/ADMIN.md @@ -3,6 +3,7 @@ ## How to backup your server with this app? You want to backup a critical "guest" Server A onto a remote "host" Server B, you need: + * Domain name of server B: `host.serverb` * Name of the server B SSH user (to be created by `borgserver`) for connection from Server A: `borgservera` * **Strong passphrase** to encrypt your backups on host Server B. And to **restore your backups**!! @@ -15,9 +16,10 @@ You want to backup a critical "guest" Server A onto a remote "host" Server B, yo You should received an email after the first backup succeeded. ### Set up Borg Backup App on guest Server A + Firstly, set up the Borg Backup App (`borg`) on the guest Server A you want to backup: -``` +```bash $ yunohost app install borg In which borg repository location do you want to backup your files ?: user@host.serverb:/remote/repository Provide a strong passphrase to encrypt your backups. No blank space: @@ -29,7 +31,9 @@ Do you want admin to receive mail notifications on backups ? [always | errors_on ``` #### Syntax to define a backup time schedule + You can schedule regular backups at specific time. Only one regular time schedule is possible for one `borg` instance, see below for workaround. Some examples: + * Monthly : * Weekly : * Daily : Daily at midnight @@ -37,25 +41,32 @@ You can schedule regular backups at specific time. Only one regular time schedul * Sat *-*-1..7 18:00:00 : The first saturday of every month at 18:00 * 4:00 : Every day at 4 AM * 5,17:00 : Every day at 5 AM and at 5 PM -See here for more info : https://wiki.archlinux.org/index.php/Systemd/Timers#Realtime_timer + +See here for more info : #### Information generated by Borg Backup + At the end of the installation, the Borg Backup App (``borg``) displays the SSH public key and the SSH user to give to the person who has access to the host Server B and will set up Borg Server App. -``` + +```text You should now install the "Borg Server" app on host.serverb and fill questions like this: User: servera Public key: ssh-ed25519 AAAA[...] root@guest.servera ``` + This information is also sent by email to the admin of guest Server A. If you don't find the email and you don't see the message in the log bar you can find the SSH public key with this command: -``` + +```bash $ cat /root/.ssh/id_borg_ed25519.pub ssh-ed25519 AAAA[...] root@guest.servera ``` ### Set up Borg Server App on host Server B + Secondly, set up the Borg Server App (``borgserver``) on the host Server B that will store your backups: -``` + +```bash $ yunohost app install borgserver Indicate the ssh user to create: servera Indicate the public key given by Borg Backup app (borg) setup: ssh-ed25519 AAAA[...] root@guest.servera @@ -63,43 +74,51 @@ Indicate the storage quota: 5G ``` ### Test the Borg Apps setup + At this step your backup should run at the scheduled time. Note that the first backup can take very long, as much data has to be copied through ssh. Following backups are incremental: only newly generated data since last backup will be copied. If you want to test correct Borg Apps setup before scheduled time, you can start a backup manually on guest Server A: -``` -$ systemctl start borg + +```bash +systemctl start borg ``` Next you can check presence of your backup repository on host Server B: + +```bash +BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list servera@host.serverb:~/backup ``` -$ BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list servera@host.serverb:~/backup -``` + You will need the passphrase to run ``borg`` commands on the backup repository created on the host Server B. ## Check regularly your backup + If you want to be sure to be able to restore your server, you should try to restore regularly the archives. But this process is quite time consumming. You should at least: - * Keep your apps up to date (if apps are too old, they could be difficult to restore on a more recent recent version) - * Check regularly the presence of `info.json` and `db.sql` or `dump.sql` in your apps archives -``` + +* Keep your apps up to date (if apps are too old, they could be difficult to restore on a more recent recent version) +* Check regularly the presence of `info.json` and `db.sql` or `dump.sql` in your apps archives + +```bash borg list ./::ARCHIVE_NAME | grep info.json borg list ./::ARCHIVE_NAME | grep db.sql borg list ./::ARCHIVE_NAME | grep dump.sql ``` - * Be sure to have your passphrase available even if your server is completely broken + +* Be sure to have your passphrase available even if your server is completely broken ## How to restore a complete system *For infos on restoring process, check [this yunohost forum thread](https://forum.yunohost.org/t/restoring-whole-yunohost-from-borg-backups/12705/3) and [that one](https://forum.yunohost.org/t/how-to-properly-backup-and-restore/12583/3), also [using Borg with sshkeys](https://thisiscasperslife.wordpress.com/2017/11/28/using-borg-backup-across-ssh-with-sshkeys/), the [`borg extract` documentation](https://borgbackup.readthedocs.io/en/stable/usage/extract.html), and this [general tutorial on Borg Backup](https://practical-admin.com/blog/backups-using-borg/).* In the following explanations: -- the server to backup/restore will be called: `yuno` -- the remote server that receives and store the back will be called: `rem` -- `rem` is accessible at the domain `rem.tld` -- the remote user on `rem` which owns the Borg backups will be called `yurem` -- backup files will be stored in `rem` in the directory: `/home/yurem/backup` +* the server to backup/restore will be called: `yuno` +* the remote server that receives and store the back will be called: `rem` +* `rem` is accessible at the domain `rem.tld` +* the remote user on `rem` which owns the Borg backups will be called `yurem` +* backup files will be stored in `rem` in the directory: `/home/yurem/backup` ### Overview @@ -125,6 +144,7 @@ If you don't want to restore the whole system, just some apps, you can skip some The idea here is just to install Borg, not in order to create backups, but only to use Borg commands to import remote backups. So for example, you can install it doing the following: + ```bash sudo yunohost app install borg -a "server=rem.tld&ssh_user=yurem&conf=0&data=0&apps=hextris&on_calendar=2:30" ``` @@ -200,23 +220,28 @@ sudo yunohost backup restore auto_borg_XX_XX_XX_XX:XX --apps ## Tips ### Edit the list of YunoHost apps to backup -``yunohost app setting borg apps -v "nextcloud,wordpress"`` + +`yunohost app setting borg apps -v "nextcloud,wordpress"` ### Other usefull borg commands + [Get the storage space used by the backup repository on the host server](https://borgbackup.readthedocs.io/en/stable/usage/info.html) -``borg info /home/servera/backup`` +`borg info /home/servera/backup` ### Backup YunoHost apps with different criticallity levels If you want to backup your guest server: + * with different YunoHost apps * at different regular time schedule * on different host servers Then you can set up multiple instances of the Borg Apps on same servers. For instance: + * Borg Backup instance ``borg``: backup nextcloud daily on host Server B * Borg Backup instance ``borg__2``: backup all other YunoHost apps weekly on host Server C ### Settings location + Settings of apps are in /etc/yunohost/apps/*/settings.yml, so are the settings for borg_ynh as well. Be careful though to not savagely manually edit them if you don't know what you're doing. diff --git a/doc/DECSRIPTION.md b/doc/DECSRIPTION.md index 0aa30bf..806909c 100644 --- a/doc/DECSRIPTION.md +++ b/doc/DECSRIPTION.md @@ -1 +1,3 @@ -A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. + +This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index a1e6b24..9d15e11 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,3 +1,5 @@ +You should check out the admin documentation of this app after installation for more info! + If you selected a remote borg server as backup target, you should now install the "Borg Server" app on __SERVER__ and with the following credentials: User: __SSH_USER__ From 4bfd7594d1f67345b1d522f4f1ecb435af49583e Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 6 Jan 2024 12:32:11 +0000 Subject: [PATCH 05/35] Auto-update README --- README.md | 225 --------------------------------------------------- README_fr.md | 225 --------------------------------------------------- 2 files changed, 450 deletions(-) diff --git a/README.md b/README.md index bf1a8f3..83cb6ca 100644 --- a/README.md +++ b/README.md @@ -19,231 +19,6 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Backup your server on a host server using Borg **Shipped version:** 1.1.16~ynh30 -## Disclaimers / important information - -## :warning: NB. : This doc is partially obsolete and should be reworked! :warning: - -## How to backup your server with this app? - -You want to backup a critical "guest" Server A onto a remote "host" Server B, you need: -* Domain name of server B: `host.serverb` -* Name of the server B SSH user (to be created by `borgserver`) for connection from Server A: `borgservera` -* **Strong passphrase** to encrypt your backups on host Server B. And to **restore your backups**!! -* IDs of YunoHost apps you want to backup -* Regular time schedule for your backups, see below -* Install Borg Backup App (`borg`) on guest Server A -* Install Borg Server App (`borgserver`) on host Server B -* Save the passphrase in another place than your server. Without the passphrase, you won't be able to restore data. - -You should received an email after the first backup succeeded. - -### Set up Borg Backup App on guest Server A -Firstly, set up the Borg Backup App (`borg`) on the guest Server A you want to backup: - -``` -$ yunohost app install borg -In which borg repository location do you want to backup your files ?: user@host.serverb:/remote/repository -Provide a strong passphrase to encrypt your backups. No blank space: -Should Borg backup your YunoHost configuration? [yes | no] (default: yes): -Should Borg backup emails and user home directory? [yes | no] (default: yes): -Which apps should Borg backup ? (default: all): -With which regular time schedule should the backups be performed? (see systemd OnCalendar format) (default: Daily): -Do you want admin to receive mail notifications on backups ? [always | errors_only | never]: never -``` - -#### Syntax to define a backup time schedule -You can schedule regular backups at specific time. Only one regular time schedule is possible for one `borg` instance, see below for workaround. Some examples: -* Monthly : -* Weekly : -* Daily : Daily at midnight -* Hourly : Hourly o Clock -* Sat *-*-1..7 18:00:00 : The first saturday of every month at 18:00 -* 4:00 : Every day at 4 AM -* 5,17:00 : Every day at 5 AM and at 5 PM -See here for more info : https://wiki.archlinux.org/index.php/Systemd/Timers#Realtime_timer - -#### Information generated by Borg Backup -At the end of the installation, the Borg Backup App (``borg``) displays the SSH public key and the SSH user to give to the person who has access to the host Server B and will set up Borg Server App. -``` -You should now install the "Borg Server" app on host.serverb and fill questions like this: -User: servera -Public key: ssh-ed25519 AAAA[...] root@guest.servera -``` -This information is also sent by email to the admin of guest Server A. -If you don't find the email and you don't see the message in the log bar you can find the SSH public key with this command: -``` -$ cat /root/.ssh/id_borg_ed25519.pub -ssh-ed25519 AAAA[...] root@guest.servera -``` - -### Set up Borg Server App on host Server B -Secondly, set up the Borg Server App (``borgserver``) on the host Server B that will store your backups: -``` -$ yunohost app install borgserver -Indicate the ssh user to create: servera -Indicate the public key given by Borg Backup app (borg) setup: ssh-ed25519 AAAA[...] root@guest.servera -Indicate the storage quota: 5G -``` - -### Test the Borg Apps setup -At this step your backup should run at the scheduled time. Note that the first backup can take very long, as much data has to be copied through ssh. Following backups are incremental: only newly generated data since last backup will be copied. - -If you want to test correct Borg Apps setup before scheduled time, you can start a backup manually on guest Server A: -``` -$ systemctl start borg -``` - -Next you can check presence of your backup repository on host Server B: -``` -$ BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list servera@host.serverb:~/backup -``` -You will need the passphrase to run ``borg`` commands on the backup repository created on the host Server B. - -## Check regularly your backup -If you want to be sure to be able to restore your server, you should try to restore regularly the archives. But this process is quite time consumming. - -You should at least: - * Keep your apps up to date (if apps are too old, they could be difficult to restore on a more recent recent version) - * Check regularly the presence of `info.json` and `db.sql` or `dump.sql` in your apps archives -``` -borg list ./::ARCHIVE_NAME | grep info.json -borg list ./::ARCHIVE_NAME | grep db.sql -borg list ./::ARCHIVE_NAME | grep dump.sql -``` - * Be sure to have your passphrase available even if your server is completely broken - -## How to restore a complete system - -*For infos on restoring process, check [this yunohost forum thread](https://forum.yunohost.org/t/restoring-whole-yunohost-from-borg-backups/12705/3) and [that one](https://forum.yunohost.org/t/how-to-properly-backup-and-restore/12583/3), also [using Borg with sshkeys](https://thisiscasperslife.wordpress.com/2017/11/28/using-borg-backup-across-ssh-with-sshkeys/), the [`borg extract` documentation](https://borgbackup.readthedocs.io/en/stable/usage/extract.html), and this [general tutorial on Borg Backup](https://practical-admin.com/blog/backups-using-borg/).* - -In the following explanations: -- the server to backup/restore will be called: `yuno` -- the remote server that receives and store the back will be called: `rem` -- `rem` is accessible at the domain `rem.tld` -- the remote user on `rem` which owns the Borg backups will be called `yurem` -- backup files will be stored in `rem` in the directory: `/home/yurem/backup` - - -### Overview - -The idea here, if you need to restore a whole yunohost system is: - -1. Install a new Debian VM -2. Install YunoHost in it the usual way -3. Go through YunoHost postinstall (parameters you will supply are not crucial, as they will be replaced by the restore) -4. Install Borg -5. Setup `rem` to accept ssh connections from `yuno` -6. Use Borg to import backups from `rem` to `yuno` -7. Restore Borg backups with the `yunohost backup restore` command, first config, then data, then each app one at a time -8. Remove the Borg app and restore it - -### Make it possible for `yuno` to connect to `rem` with Borg - -At this stage, we will assume that `yuno` is a freshly installed YunoHost (based on Buster in my case). You should also have performed the YunoHost postinstall. - -If you don't want to restore the whole system, just some apps, you can skip some of the steps below. - -#### Install the Borg YunoHost app in `yuno` - -The idea here is just to install Borg, not in order to create backups, but only to use Borg commands to import remote backups. - -So for example, you can install it doing the following: -```bash -sudo yunohost app install borg -a "server=rem.tld&ssh_user=yurem&conf=0&data=0&apps=hextris&on_calendar=2:30" -``` - -#### Make sure that `rem` accepts ssh connections from `yuno` - -In `yuno` you will need to get the ssh key that borg just created while installing: `sudo cat /root/.ssh/id_borg_ed25519.pub`, copy it to clipboard. - -Connect via ssh to `rem`, go to `/home/yurem/.ssh/authorized_keys`, and past the Borg public key you got at previous step. - -Now to make sure this worked, you can try to SSH from `yuno` to `rem`. -In `yuno` : `ssh -i /root/.ssh/id_borg_ed25519 yurem@rem.tld` . If you can get into `rem` , without it prompting for a password, then you're good to continue :) - -### Restore backups to `yuno` - -⚠️ For the commands in the following section to work, you will need to be root in `yuno` (you can become root running `sudo su`). - -⚠️ Restoration of backups can take quite a while, you'd better do them in a separate process, so that it doesn't stop if your terminal session gets closed. For this, you can for example use [tmux](https://www.howtogeek.com/671422/how-to-use-tmux-on-linux-and-why-its-better-than-screen/). - -In `yuno` now, you should be able to list backups in `rem` with the following command: - -```bash -SRV=yurem@rem.tld:/home/yurem/backup -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list $SRV -``` - -You can then reimport one to `yuno` with: - -```bash -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg export-tar $SRV::auto_BACKUP_NAME /home/yunohost.backup/archives/auto_BACKUP_NAME.tar.gz -``` - -And then restore the archive in `yuno` with: - -```bash -yunohost backup restore auto_BACKUP_NAME --system # for config and data backups -yunohost backup restore auto_BACKUP_NAME --apps # for other backups (=apps) -``` - -### And Nextcloud? It's super heavy!! - -For Nextcloud, the best is probably to reimport the backup without the data. And to import the data manually. - -For that, you can do the following (as root): - -```bash -SRV=yurem@rem.tld:/home/yurem/backup - -# export the app without data -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg export-tar -e apps/nextcloud/backup/home/yunohost.app $SRV::auto_nextcloud_XX_XX_XX_XX:XX /home/yunohost.backup/archives/auto_nextcloud_XX_XX_XX_XX:XX.tar.gz - -# extract the data from the backup to the nextcloud folder -cd /home/yunohost.app/nextcloud -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg extract $SRV::auto_nextcloud_XX_XX_XX_XX:XX apps/nextcloud/backup/home/yunohost.app/nextcloud/ -mv apps/nextcloud/backup/home/yunohost.app/nextcloud/data data -rm -r apps - -# now you can simply restore nextcloud app -yunohost backup restore auto_nextcloud_XX_XX_XX_XX:XX --apps -``` - -### Restore Borg - -Once you've restored the whole system, you will probably want to restore the Borg app as well. - -For that, remove the "dummy" Borg you installed to do the restoration, and restore Borg the same ways as for other apps: - -```bash -sudo yunohost app remove borg -sudo yunohost backup restore auto_borg_XX_XX_XX_XX:XX --apps -``` - -## Tips - -### Edit the list of YunoHost apps to backup -``yunohost app setting borg apps -v "nextcloud,wordpress"`` - -### Other usefull borg commands -[Get the storage space used by the backup repository on the host server](https://borgbackup.readthedocs.io/en/stable/usage/info.html) -``borg info /home/servera/backup`` - -### Backup YunoHost apps with different criticallity levels - -If you want to backup your guest server: -* with different YunoHost apps -* at different regular time schedule -* on different host servers - -Then you can set up multiple instances of the Borg Apps on same servers. -For instance: -* Borg Backup instance ``borg``: backup nextcloud daily on host Server B -* Borg Backup instance ``borg__2``: backup all other YunoHost apps weekly on host Server C - -### Settings location -Settings of apps are in /etc/yunohost/apps/*/settings.yml, so are the settings for borg_ynh as well. Be careful though to not savagely manually edit them if you don't know what you're doing. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index d885686..f7dd421 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,231 +19,6 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Sauvegardez votre serveur sur un serveur distant avec Borg **Version incluse :** 1.1.16~ynh30 -## Avertissements / informations importantes - -## :warning: NB. : This doc is partially obsolete and should be reworked! :warning: - -## How to backup your server with this app? - -You want to backup a critical "guest" Server A onto a remote "host" Server B, you need: -* Domain name of server B: `host.serverb` -* Name of the server B SSH user (to be created by `borgserver`) for connection from Server A: `borgservera` -* **Strong passphrase** to encrypt your backups on host Server B. And to **restore your backups**!! -* IDs of YunoHost apps you want to backup -* Regular time schedule for your backups, see below -* Install Borg Backup App (`borg`) on guest Server A -* Install Borg Server App (`borgserver`) on host Server B -* Save the passphrase in another place than your server. Without the passphrase, you won't be able to restore data. - -You should received an email after the first backup succeeded. - -### Set up Borg Backup App on guest Server A -Firstly, set up the Borg Backup App (`borg`) on the guest Server A you want to backup: - -``` -$ yunohost app install borg -In which borg repository location do you want to backup your files ?: user@host.serverb:/remote/repository -Provide a strong passphrase to encrypt your backups. No blank space: -Should Borg backup your YunoHost configuration? [yes | no] (default: yes): -Should Borg backup emails and user home directory? [yes | no] (default: yes): -Which apps should Borg backup ? (default: all): -With which regular time schedule should the backups be performed? (see systemd OnCalendar format) (default: Daily): -Do you want admin to receive mail notifications on backups ? [always | errors_only | never]: never -``` - -#### Syntax to define a backup time schedule -You can schedule regular backups at specific time. Only one regular time schedule is possible for one `borg` instance, see below for workaround. Some examples: -* Monthly : -* Weekly : -* Daily : Daily at midnight -* Hourly : Hourly o Clock -* Sat *-*-1..7 18:00:00 : The first saturday of every month at 18:00 -* 4:00 : Every day at 4 AM -* 5,17:00 : Every day at 5 AM and at 5 PM -See here for more info : https://wiki.archlinux.org/index.php/Systemd/Timers#Realtime_timer - -#### Information generated by Borg Backup -At the end of the installation, the Borg Backup App (``borg``) displays the SSH public key and the SSH user to give to the person who has access to the host Server B and will set up Borg Server App. -``` -You should now install the "Borg Server" app on host.serverb and fill questions like this: -User: servera -Public key: ssh-ed25519 AAAA[...] root@guest.servera -``` -This information is also sent by email to the admin of guest Server A. -If you don't find the email and you don't see the message in the log bar you can find the SSH public key with this command: -``` -$ cat /root/.ssh/id_borg_ed25519.pub -ssh-ed25519 AAAA[...] root@guest.servera -``` - -### Set up Borg Server App on host Server B -Secondly, set up the Borg Server App (``borgserver``) on the host Server B that will store your backups: -``` -$ yunohost app install borgserver -Indicate the ssh user to create: servera -Indicate the public key given by Borg Backup app (borg) setup: ssh-ed25519 AAAA[...] root@guest.servera -Indicate the storage quota: 5G -``` - -### Test the Borg Apps setup -At this step your backup should run at the scheduled time. Note that the first backup can take very long, as much data has to be copied through ssh. Following backups are incremental: only newly generated data since last backup will be copied. - -If you want to test correct Borg Apps setup before scheduled time, you can start a backup manually on guest Server A: -``` -$ systemctl start borg -``` - -Next you can check presence of your backup repository on host Server B: -``` -$ BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list servera@host.serverb:~/backup -``` -You will need the passphrase to run ``borg`` commands on the backup repository created on the host Server B. - -## Check regularly your backup -If you want to be sure to be able to restore your server, you should try to restore regularly the archives. But this process is quite time consumming. - -You should at least: - * Keep your apps up to date (if apps are too old, they could be difficult to restore on a more recent recent version) - * Check regularly the presence of `info.json` and `db.sql` or `dump.sql` in your apps archives -``` -borg list ./::ARCHIVE_NAME | grep info.json -borg list ./::ARCHIVE_NAME | grep db.sql -borg list ./::ARCHIVE_NAME | grep dump.sql -``` - * Be sure to have your passphrase available even if your server is completely broken - -## How to restore a complete system - -*For infos on restoring process, check [this yunohost forum thread](https://forum.yunohost.org/t/restoring-whole-yunohost-from-borg-backups/12705/3) and [that one](https://forum.yunohost.org/t/how-to-properly-backup-and-restore/12583/3), also [using Borg with sshkeys](https://thisiscasperslife.wordpress.com/2017/11/28/using-borg-backup-across-ssh-with-sshkeys/), the [`borg extract` documentation](https://borgbackup.readthedocs.io/en/stable/usage/extract.html), and this [general tutorial on Borg Backup](https://practical-admin.com/blog/backups-using-borg/).* - -In the following explanations: -- the server to backup/restore will be called: `yuno` -- the remote server that receives and store the back will be called: `rem` -- `rem` is accessible at the domain `rem.tld` -- the remote user on `rem` which owns the Borg backups will be called `yurem` -- backup files will be stored in `rem` in the directory: `/home/yurem/backup` - - -### Overview - -The idea here, if you need to restore a whole yunohost system is: - -1. Install a new Debian VM -2. Install YunoHost in it the usual way -3. Go through YunoHost postinstall (parameters you will supply are not crucial, as they will be replaced by the restore) -4. Install Borg -5. Setup `rem` to accept ssh connections from `yuno` -6. Use Borg to import backups from `rem` to `yuno` -7. Restore Borg backups with the `yunohost backup restore` command, first config, then data, then each app one at a time -8. Remove the Borg app and restore it - -### Make it possible for `yuno` to connect to `rem` with Borg - -At this stage, we will assume that `yuno` is a freshly installed YunoHost (based on Buster in my case). You should also have performed the YunoHost postinstall. - -If you don't want to restore the whole system, just some apps, you can skip some of the steps below. - -#### Install the Borg YunoHost app in `yuno` - -The idea here is just to install Borg, not in order to create backups, but only to use Borg commands to import remote backups. - -So for example, you can install it doing the following: -```bash -sudo yunohost app install borg -a "server=rem.tld&ssh_user=yurem&conf=0&data=0&apps=hextris&on_calendar=2:30" -``` - -#### Make sure that `rem` accepts ssh connections from `yuno` - -In `yuno` you will need to get the ssh key that borg just created while installing: `sudo cat /root/.ssh/id_borg_ed25519.pub`, copy it to clipboard. - -Connect via ssh to `rem`, go to `/home/yurem/.ssh/authorized_keys`, and past the Borg public key you got at previous step. - -Now to make sure this worked, you can try to SSH from `yuno` to `rem`. -In `yuno` : `ssh -i /root/.ssh/id_borg_ed25519 yurem@rem.tld` . If you can get into `rem` , without it prompting for a password, then you're good to continue :) - -### Restore backups to `yuno` - -⚠️ For the commands in the following section to work, you will need to be root in `yuno` (you can become root running `sudo su`). - -⚠️ Restoration of backups can take quite a while, you'd better do them in a separate process, so that it doesn't stop if your terminal session gets closed. For this, you can for example use [tmux](https://www.howtogeek.com/671422/how-to-use-tmux-on-linux-and-why-its-better-than-screen/). - -In `yuno` now, you should be able to list backups in `rem` with the following command: - -```bash -SRV=yurem@rem.tld:/home/yurem/backup -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list $SRV -``` - -You can then reimport one to `yuno` with: - -```bash -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg export-tar $SRV::auto_BACKUP_NAME /home/yunohost.backup/archives/auto_BACKUP_NAME.tar.gz -``` - -And then restore the archive in `yuno` with: - -```bash -yunohost backup restore auto_BACKUP_NAME --system # for config and data backups -yunohost backup restore auto_BACKUP_NAME --apps # for other backups (=apps) -``` - -### And Nextcloud? It's super heavy!! - -For Nextcloud, the best is probably to reimport the backup without the data. And to import the data manually. - -For that, you can do the following (as root): - -```bash -SRV=yurem@rem.tld:/home/yurem/backup - -# export the app without data -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg export-tar -e apps/nextcloud/backup/home/yunohost.app $SRV::auto_nextcloud_XX_XX_XX_XX:XX /home/yunohost.backup/archives/auto_nextcloud_XX_XX_XX_XX:XX.tar.gz - -# extract the data from the backup to the nextcloud folder -cd /home/yunohost.app/nextcloud -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg extract $SRV::auto_nextcloud_XX_XX_XX_XX:XX apps/nextcloud/backup/home/yunohost.app/nextcloud/ -mv apps/nextcloud/backup/home/yunohost.app/nextcloud/data data -rm -r apps - -# now you can simply restore nextcloud app -yunohost backup restore auto_nextcloud_XX_XX_XX_XX:XX --apps -``` - -### Restore Borg - -Once you've restored the whole system, you will probably want to restore the Borg app as well. - -For that, remove the "dummy" Borg you installed to do the restoration, and restore Borg the same ways as for other apps: - -```bash -sudo yunohost app remove borg -sudo yunohost backup restore auto_borg_XX_XX_XX_XX:XX --apps -``` - -## Tips - -### Edit the list of YunoHost apps to backup -``yunohost app setting borg apps -v "nextcloud,wordpress"`` - -### Other usefull borg commands -[Get the storage space used by the backup repository on the host server](https://borgbackup.readthedocs.io/en/stable/usage/info.html) -``borg info /home/servera/backup`` - -### Backup YunoHost apps with different criticallity levels - -If you want to backup your guest server: -* with different YunoHost apps -* at different regular time schedule -* on different host servers - -Then you can set up multiple instances of the Borg Apps on same servers. -For instance: -* Borg Backup instance ``borg``: backup nextcloud daily on host Server B -* Borg Backup instance ``borg__2``: backup all other YunoHost apps weekly on host Server C - -### Settings location -Settings of apps are in /etc/yunohost/apps/*/settings.yml, so are the settings for borg_ynh as well. Be careful though to not savagely manually edit them if you don't know what you're doing. - ## Documentations et ressources * Site officiel de l’app : From cbf10085f5d4b6a0e32c7d0ebef960fc6d2210e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 6 Jan 2024 13:39:05 +0100 Subject: [PATCH 06/35] local mode --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index 688cc6f..8f1b9ec 100755 --- a/scripts/install +++ b/scripts/install @@ -21,6 +21,9 @@ if [[ "$repository" =~ $ssh_regex ]]; then if [[ -n "$port" ]]; then server="[$server]$port" fi +else + ssh_user="" + server="" fi ynh_app_setting_set --app=$app --key=ssh_user --value="$ssh_user" From 3b385606e1dfc94119efaa4a2f0d96b2b90541a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 6 Jan 2024 14:21:00 +0100 Subject: [PATCH 07/35] fix doc name --- doc/{DECSRIPTION.md => DESCRIPTION.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/{DECSRIPTION.md => DESCRIPTION.md} (100%) diff --git a/doc/DECSRIPTION.md b/doc/DESCRIPTION.md similarity index 100% rename from doc/DECSRIPTION.md rename to doc/DESCRIPTION.md From e209f5ddf031f0a7b071e332ce5243708f302fb1 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 6 Jan 2024 13:21:05 +0000 Subject: [PATCH 08/35] Auto-update README --- README.md | 5 ++++- README_fr.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 83cb6ca..6c5d61d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,10 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Backup your server on a host server using Borg +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. + +This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. + **Shipped version:** 1.1.16~ynh30 ## Documentation and resources diff --git a/README_fr.md b/README_fr.md index f7dd421..ffac6fb 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,7 +16,10 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -Sauvegardez votre serveur sur un serveur distant avec Borg +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. + +This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. + **Version incluse :** 1.1.16~ynh30 ## Documentations et ressources From f2f0c052c4b22588d78621fb1c9f5a4ec63bf312 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 10 Apr 2024 21:12:05 +0200 Subject: [PATCH 09/35] cli -> command-line Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> --- doc/POST_INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 9d15e11..8085716 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -5,7 +5,7 @@ If you selected a remote borg server as backup target, you should now install th User: __SSH_USER__ Public key: __PUBLIC_KEY__ -Or if you want to use cli: +Or if you want to use command-line: `yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh -a "ssh_user=__SSH_USER__&public_key=__PUBLIC_KEY__"` From 9a2347b9ab8100ec1f27a526f79b7d44d011ebc1 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 10 Apr 2024 19:12:10 +0000 Subject: [PATCH 10/35] Auto-update READMEs --- ALL_README.md | 6 ++++++ README.md | 20 ++++++++++---------- README_eu.md | 43 +++++++++++++++++++++++++++++++++++++++++++ README_fr.md | 26 +++++++++++++------------- README_gl.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 23 deletions(-) create mode 100644 ALL_README.md create mode 100644 README_eu.md create mode 100644 README_gl.md diff --git a/ALL_README.md b/ALL_README.md new file mode 100644 index 0000000..77b7509 --- /dev/null +++ b/ALL_README.md @@ -0,0 +1,6 @@ +# All available README files by language + +- [Read the README in English](README.md) +- [Irakurri README euskaraz](README_eu.md) +- [Lire le README en français](README_fr.md) +- [Le o README en galego](README_gl.md) diff --git a/README.md b/README.md index 6c5d61d..e1b19a4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ @@ -9,10 +9,10 @@ It shall NOT be edited by hand. [![Install Borg Backup with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borg) -*[Lire ce readme en français.](./README_fr.md)* +*[Read this README in other languages.](./ALL_README.md)* -> *This package allows you to install Borg Backup 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.* +> *This package allows you to install Borg Backup 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 @@ -24,17 +24,17 @@ This is the Borg Backup App to be installed on a server to backup. It works toge **Shipped version:** 1.1.16~ynh30 ## Documentation and resources -* Official app website: -* YunoHost Store: -* Report a bug: +- Official app website: +- YunoHost Store: +- Report a bug: ## Developer info -Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/borg_ynh/tree/testing). +Please send your pull request to the [`testing` branch](https://github.com/YunoHost-Apps/borg_ynh/tree/testing). -To try the testing branch, please proceed like that. +To try the `testing` branch, please proceed like that: -``` bash +```bash sudo yunohost app install https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug or sudo yunohost app upgrade borg -u https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug diff --git a/README_eu.md b/README_eu.md new file mode 100644 index 0000000..4d72500 --- /dev/null +++ b/README_eu.md @@ -0,0 +1,43 @@ + + +# Borg Backup YunoHost-erako + +[![Integrazio maila](https://dash.yunohost.org/integration/borg.svg)](https://dash.yunohost.org/appci/app/borg) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/borg.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/borg.maintain.svg) + +[![Instalatu Borg Backup YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borg) + +*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)* + +> *Pakete honek Borg Backup YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.* +> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.* + +## Aurreikuspena + +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. + +This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. + + +**Paketatutako bertsioa:** 1.1.16~ynh30 +## Dokumentazioa eta baliabideak + +- Aplikazioaren webgune ofiziala: +- YunoHost Denda: +- Eman errore baten berri: + +## Garatzaileentzako informazioa + +Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/borg_ynh/tree/testing). + +`testing` abarra probatzeko, ondorengoa egin: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug +edo +sudo yunohost app upgrade borg -u https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug +``` + +**Informazio gehiago aplikazioaren paketatzeari buruz:** diff --git a/README_fr.md b/README_fr.md index ffac6fb..4a7741a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,6 +1,6 @@ # Borg Backup pour YunoHost @@ -9,10 +9,10 @@ It shall NOT be edited by hand. [![Installer Borg Backup avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borg) -*[Read this readme in english.](./README.md)* +*[Lire le README dans d'autres langues.](./ALL_README.md)* -> *Ce package vous permet d’installer Borg Backup rapidement et simplement sur un serveur YunoHost. -Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* +> *Ce package vous permet d’installer Borg Backup rapidement et simplement sur un serveur YunoHost.* +> *Si vous n’avez pas YunoHost, consultez [ce guide](https://yunohost.org/install) pour savoir comment l’installer et en profiter.* ## Vue d’ensemble @@ -21,23 +21,23 @@ A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgback This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. -**Version incluse :** 1.1.16~ynh30 +**Version incluse :** 1.1.16~ynh30 ## Documentations et ressources -* Site officiel de l’app : -* YunoHost Store: -* Signaler un bug : +- Site officiel de l’app : +- YunoHost Store : +- Signaler un bug : ## Informations pour les développeurs -Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/borg_ynh/tree/testing). +Merci de faire vos pull request sur la [branche `testing`](https://github.com/YunoHost-Apps/borg_ynh/tree/testing). -Pour essayer la branche testing, procédez comme suit. +Pour essayer la branche `testing`, procédez comme suit : -``` bash +```bash sudo yunohost app install https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug ou sudo yunohost app upgrade borg -u https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug ``` -**Plus d’infos sur le packaging d’applications :** \ No newline at end of file +**Plus d’infos sur le packaging d’applications :** diff --git a/README_gl.md b/README_gl.md new file mode 100644 index 0000000..f380b1b --- /dev/null +++ b/README_gl.md @@ -0,0 +1,43 @@ + + +# Borg Backup para YunoHost + +[![Nivel de integración](https://dash.yunohost.org/integration/borg.svg)](https://dash.yunohost.org/appci/app/borg) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/borg.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/borg.maintain.svg) + +[![Instalar Borg Backup con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borg) + +*[Le este README en outros idiomas.](./ALL_README.md)* + +> *Este paquete permíteche instalar Borg Backup de xeito rápido e doado nun servidor YunoHost.* +> *Se non usas YunoHost, le a [documentación](https://yunohost.org/install) para saber como instalalo.* + +## Vista xeral + +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. + +This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. + + +**Versión proporcionada:** 1.1.16~ynh30 +## Documentación e recursos + +- Web oficial da app: +- Tenda YunoHost: +- Informar dun problema: + +## Info de desenvolvemento + +Envía a túa colaboración á [rama `testing`](https://github.com/YunoHost-Apps/borg_ynh/tree/testing). + +Para probar a rama `testing`, procede deste xeito: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug +ou +sudo yunohost app upgrade borg -u https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug +``` + +**Máis info sobre o empaquetado da app:** From 215b23fef5603ebabaf1b7a924669d0f7ed55a3c Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 10 Apr 2024 23:18:53 +0200 Subject: [PATCH 11/35] [fix] Bookworm install --- manifest.toml | 4 ++-- scripts/_common.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifest.toml b/manifest.toml index ced07d3..fc59b18 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "Borg Backup" description.en = "Backup your server on a host server using Borg" description.fr = "Sauvegardez votre serveur sur un serveur distant avec Borg" -version = "1.1.16~ynh30" +version = "1.2.8~ynh1" maintainers = ["ljf"] @@ -92,6 +92,6 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen "python3-setuptools", "python3-venv", "virtualenv", - "libfuse-dev", + "libfuse3-dev", "pkg-config", ] diff --git a/scripts/_common.sh b/scripts/_common.sh index af21316..bf7b965 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -BORG_VERSION=1.1.16 +BORG_VERSION=1.2.8 #================================================= # PERSONAL HELPERS @@ -19,9 +19,9 @@ install_borg_with_pip () { python3 -m venv /opt/borg-env /opt/borg-env/bin/python /opt/borg-env/bin/pip install pip -U /opt/borg-env/bin/python /opt/borg-env/bin/pip install setuptools -U - /opt/borg-env/bin/python /opt/borg-env/bin/pip install wheel + /opt/borg-env/bin/python /opt/borg-env/bin/pip install wheel -U ynh_print_info --message="Installing/compiling borg, this may take some time..." - /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[fuse]==$BORG_VERSION + /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[pyfuse3]==$BORG_VERSION echo "#!/bin/bash /opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg touch "/opt/borg-env/$(ynh_get_debian_release)" From 108341bbf4f20713aaf182bb0479f363370ada79 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 10 Apr 2024 21:18:56 +0000 Subject: [PATCH 12/35] Auto-update READMEs --- README.md | 2 +- README_eu.md | 2 +- README_fr.md | 2 +- README_gl.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e1b19a4..b767db2 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgback This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. -**Shipped version:** 1.1.16~ynh30 +**Shipped version:** 1.2.8~ynh1 ## Documentation and resources - Official app website: diff --git a/README_eu.md b/README_eu.md index 4d72500..0796b1a 100644 --- a/README_eu.md +++ b/README_eu.md @@ -21,7 +21,7 @@ A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgback This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. -**Paketatutako bertsioa:** 1.1.16~ynh30 +**Paketatutako bertsioa:** 1.2.8~ynh1 ## Dokumentazioa eta baliabideak - Aplikazioaren webgune ofiziala: diff --git a/README_fr.md b/README_fr.md index 4a7741a..1d6b3a0 100644 --- a/README_fr.md +++ b/README_fr.md @@ -21,7 +21,7 @@ A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgback This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. -**Version incluse :** 1.1.16~ynh30 +**Version incluse :** 1.2.8~ynh1 ## Documentations et ressources - Site officiel de l’app : diff --git a/README_gl.md b/README_gl.md index f380b1b..28a3eaf 100644 --- a/README_gl.md +++ b/README_gl.md @@ -21,7 +21,7 @@ A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgback This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. -**Versión proporcionada:** 1.1.16~ynh30 +**Versión proporcionada:** 1.2.8~ynh1 ## Documentación e recursos - Web oficial da app: From 31b8989644bd219647926aa1adc8687fd3d27456 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Mon, 15 Apr 2024 20:44:06 +0200 Subject: [PATCH 13/35] [enh] Remove some tutorial comments Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> --- manifest.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifest.toml b/manifest.toml index fc59b18..ece5305 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,13 +19,13 @@ fund = "https://www.borgbackup.org/support/fund.html" [integration] yunohost = ">= 11.0.9" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +architectures = "all" multi_instance = true ldap = "not_relevant" sso = "not_relevant" -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install] [install.repository] From 49d3fa94813febf2ff1bbf6cdc8c75acb973bfb0 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 15 Apr 2024 18:44:10 +0000 Subject: [PATCH 14/35] Auto-update READMEs --- ALL_README.md | 1 + README_zh_Hans.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 README_zh_Hans.md diff --git a/ALL_README.md b/ALL_README.md index 77b7509..a01b345 100644 --- a/ALL_README.md +++ b/ALL_README.md @@ -4,3 +4,4 @@ - [Irakurri README euskaraz](README_eu.md) - [Lire le README en français](README_fr.md) - [Le o README en galego](README_gl.md) +- [阅读中文(简体)的 README](README_zh_Hans.md) diff --git a/README_zh_Hans.md b/README_zh_Hans.md new file mode 100644 index 0000000..de8ef60 --- /dev/null +++ b/README_zh_Hans.md @@ -0,0 +1,43 @@ + + +# YunoHost 的 Borg Backup + +[![集成程度](https://dash.yunohost.org/integration/borg.svg)](https://dash.yunohost.org/appci/app/borg) ![工作状态](https://ci-apps.yunohost.org/ci/badges/borg.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/borg.maintain.svg) + +[![使用 YunoHost 安装 Borg Backup](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borg) + +*[阅读此 README 的其它语言版本。](./ALL_README.md)* + +> *通过此软件包,您可以在 YunoHost 服务器上快速、简单地安装 Borg Backup。* +> *如果您还没有 YunoHost,请参阅[指南](https://yunohost.org/install)了解如何安装它。* + +## 概况 + +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. + +This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. + + +**分发版本:** 1.2.8~ynh1 +## 文档与资源 + +- 官方应用网站: +- YunoHost 商店: +- 报告 bug: + +## 开发者信息 + +请向 [`testing` 分支](https://github.com/YunoHost-Apps/borg_ynh/tree/testing) 发送拉取请求。 + +如要尝试 `testing` 分支,请这样操作: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug +或 +sudo yunohost app upgrade borg -u https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug +``` + +**有关应用打包的更多信息:** From 8dbc95871d2d524aea74d089dfb9f227baccac47 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Mon, 15 Apr 2024 20:46:05 +0200 Subject: [PATCH 15/35] [enh] Avoid double hardcoded version string Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index bf7b965..2359906 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -BORG_VERSION=1.2.8 +BORG_VERSION=$(ynh_app_upstream_version) #================================================= # PERSONAL HELPERS From eb07777858f1f7fb475d0bdc800f54d82e4baa79 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Thu, 2 May 2024 16:52:49 +0200 Subject: [PATCH 16/35] Update doc/POST_INSTALL.md --- doc/POST_INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 8085716..0decff5 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -2,8 +2,8 @@ You should check out the admin documentation of this app after installation for If you selected a remote borg server as backup target, you should now install the "Borg Server" app on __SERVER__ and with the following credentials: -User: __SSH_USER__ -Public key: __PUBLIC_KEY__ +- User: `__SSH_USER__` +- Public key: `__PUBLIC_KEY__` Or if you want to use command-line: From 55826d9bc240890262a0402a6411b04f135706ec Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Thu, 2 May 2024 16:57:45 +0200 Subject: [PATCH 17/35] Update scripts/_common.sh: fix upstream version parsing because we can't use helper in global scope in _common.sh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2359906..80c2a5a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -BORG_VERSION=$(ynh_app_upstream_version) +BORG_VERSION=$(cat $YNH_APP_BASEDIR/manifest.toml | grep "^version" | grep -oE "[0-9.]{2,}") #================================================= # PERSONAL HELPERS From 838574f3ea92d2e8781c41ab5a04ecb8fcf2c8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 3 May 2024 10:40:11 +0200 Subject: [PATCH 18/35] Define BORG_VERSION inside of function to make use of helper --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 80c2a5a..02f22a6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,14 +4,14 @@ # COMMON VARIABLES #================================================= -BORG_VERSION=$(cat $YNH_APP_BASEDIR/manifest.toml | grep "^version" | grep -oE "[0-9.]{2,}") - #================================================= # PERSONAL HELPERS #================================================= # Install borg with pip if borg is not here install_borg_with_pip () { + BORG_VERSION=$(ynh_app_upstream_version) + if [ -d /opt/borg-env ]; then /opt/borg-env/bin/python /opt/borg-env/bin/pip list | grep "borgbackup *$BORG_VERSION" || ynh_secure_remove /opt/borg-env fi From ea3f6e34920d821bf3309758d9f33cffa9ab3082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 3 May 2024 15:31:50 +0200 Subject: [PATCH 19/35] Move /opt/borg-env, /usr/local/bin/borg,backup-with-app to install_dir --- conf/sudoer | 2 +- conf/systemd.service | 2 +- scripts/_common.sh | 24 ++++++------------------ scripts/backup | 1 - scripts/install | 6 +++--- scripts/remove | 8 -------- scripts/restore | 4 ---- scripts/upgrade | 14 ++++++++------ 8 files changed, 19 insertions(+), 42 deletions(-) diff --git a/conf/sudoer b/conf/sudoer index 6a11357..fec3569 100644 --- a/conf/sudoer +++ b/conf/sudoer @@ -1 +1 @@ -__APP__ ALL=(root) NOPASSWD: /usr/local/bin/backup-with-__APP__, /usr/local/bin/borg, /usr/bin/yunohost backup create *, /usr/bin/yunohost app setting *, /bin/ls, /usr/bin/test +__APP__ ALL=(root) NOPASSWD: __INSTALL_DIR__/backup-with-__APP__, __INSTALL_DIR__/venv/bin/borg, /usr/bin/yunohost backup create *, /usr/bin/yunohost app setting *, /bin/ls, /usr/bin/test diff --git a/conf/systemd.service b/conf/systemd.service index b2d0080..87c332f 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -4,7 +4,7 @@ After=network.target [Service] Type=oneshot -ExecStart=/usr/bin/sudo /usr/local/bin/backup-with-__APP__ __APP__ +ExecStart=/usr/bin/sudo __INSTALL_DIR__/backup-with-__APP__ __APP__ User=__APP__ Group=__APP__ diff --git a/scripts/_common.sh b/scripts/_common.sh index 02f22a6..396c10e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,26 +8,14 @@ # PERSONAL HELPERS #================================================= -# Install borg with pip if borg is not here install_borg_with_pip () { - BORG_VERSION=$(ynh_app_upstream_version) + ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv" + venvpy="$install_dir/venv/bin/python3" - if [ -d /opt/borg-env ]; then - /opt/borg-env/bin/python /opt/borg-env/bin/pip list | grep "borgbackup *$BORG_VERSION" || ynh_secure_remove /opt/borg-env - fi - if [ ! -d /opt/borg-env ]; then - python3 -m venv /opt/borg-env - /opt/borg-env/bin/python /opt/borg-env/bin/pip install pip -U - /opt/borg-env/bin/python /opt/borg-env/bin/pip install setuptools -U - /opt/borg-env/bin/python /opt/borg-env/bin/pip install wheel -U - ynh_print_info --message="Installing/compiling borg, this may take some time..." - /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[pyfuse3]==$BORG_VERSION - echo "#!/bin/bash - /opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg - touch "/opt/borg-env/$(ynh_get_debian_release)" - fi - # We need this to be executable by other borg apps - chmod a+x /usr/local/bin/borg + ynh_exec_as "$app" "$venvpy" -m pip install --upgrade setuptools wheel + + BORG_VERSION=$(ynh_app_upstream_version) + ynh_exec_as "$app" "$venvpy" -m pip install borgbackup[pyfuse3]=="$BORG_VERSION" } _gen_and_save_public_key() { diff --git a/scripts/backup b/scripts/backup index 42fc15e..964f5d9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -17,7 +17,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.timer" ynh_backup --src_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app" -ynh_backup --src_path="/usr/local/bin/backup-with-$app" ynh_backup --src_path="/etc/sudoers.d/$app" ynh_backup --src_path="/root/.ssh/id_${app}_ed25519" --not_mandatory diff --git a/scripts/install b/scripts/install index 8f1b9ec..bf707a0 100755 --- a/scripts/install +++ b/scripts/install @@ -61,9 +61,9 @@ mkdir -p /usr/share/yunohost/backup_method ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app" chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app" -ynh_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app" -chmod u+x "/usr/local/bin/backup-with-$app" -chown $app:$app "/usr/local/bin/backup-with-$app" +ynh_add_config --template="backup-with-borg" --destination="$install_dir/backup-with-$app" +chmod u+x "$install_dir/backup-with-$app" +chown "$app:$app" "$install_dir/backup-with-$app" ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app" chown root:root "/etc/sudoers.d/$app" diff --git a/scripts/remove b/scripts/remove index bcc3561..efc224d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -29,16 +29,8 @@ systemctl disable $app.timer --quiet ynh_remove_systemd_config ynh_secure_remove "/etc/systemd/system/$app.timer" -ynh_secure_remove "/usr/local/bin/backup-with-$app" ynh_secure_remove "/etc/yunohost/hooks.d/backup_method/05-${app}_app" -# Remove borg if we are removing the last borg app on the system -if [ "$(yunohost app list | grep "id: borg" | wc -l)" == "1" ] ; then - ynh_script_progression --message="Removing borg..." --weight=1 - ynh_secure_remove "/opt/borg-env" - ynh_secure_remove "/usr/local/bin/borg" -fi - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 0a41509..7f7831c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -34,10 +34,6 @@ mkdir -p /usr/share/yunohost/backup_method ynh_restore_file --origin_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app" chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app" -ynh_restore_file --origin_path="/usr/local/bin/backup-with-$app" -chmod u+x "/usr/local/bin/backup-with-$app" -chown $app:$app "/usr/local/bin/backup-with-$app" - ynh_restore_file --origin_path="/etc/sudoers.d/$app" chown root:root "/etc/sudoers.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 53d5393..174271d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -54,9 +54,11 @@ fi # Replace backports with pip [ ! -e " /etc/apt/sources.list.d/$app-stretch-backports.list" ] || rm -f /etc/apt/sources.list.d/$app-stretch-backports.list -# Reinstall borg if debian change of major version -if [ ! -f "/opt/borg-env/$(ynh_get_debian_release)" ] ; then - ynh_secure_remove /opt/borg-env +# Clear legacy stuff +if [ -d /opt/borg-env ]; then + ynh_secure_remove --file="/opt/borg-env" + ynh_secure_remove --file="/usr/local/bin/borg" + ynh_secure_remove --file="/usr/local/bin/backup-with-$app" fi #================================================= @@ -84,9 +86,9 @@ mkdir -p /usr/share/yunohost/backup_method ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app" chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app" -ynh_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app" -chmod u+x "/usr/local/bin/backup-with-$app" -chown $app:$app "/usr/local/bin/backup-with-$app" +ynh_add_config --template="backup-with-borg" --destination="$install_dir/backup-with-$app" +chmod u+x "$install_dir/backup-with-$app" +chown "$app:$app" "$install_dir/backup-with-$app" ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app" chown root:root "/etc/sudoers.d/$app" From c3e5353d397e710c5598a2e95b11100596acebd2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 3 May 2024 15:43:33 +0200 Subject: [PATCH 20/35] Rework ADMIN.md, misc wording etc --- config_panel.toml | 25 ++++----- doc/ADMIN.md | 127 ++++---------------------------------------- doc/DESCRIPTION.md | 17 +++++- doc/POST_INSTALL.md | 2 +- manifest.toml | 23 ++++---- 5 files changed, 50 insertions(+), 144 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index b5b4d41..7411482 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -3,14 +3,14 @@ version = "1.0" [main] services = [] - [main.settings] + [main.state] name = "" visible = "false" - [main.settings.state] + [main.state.state] type = "string" - [main.settings.last_run] + [main.state.last_run] type = "string" [main.general] @@ -25,7 +25,7 @@ services = [] [main.general.repository] ask.en = "Repository" type = "string" - help = "Specify a local repository like /mount/my_external_harddrive/backups or a remote repository using this format: ssh://USER@DOMAIN.TLD:PORT/~/backup . If you plan to use borgserver_ynh app : 'USER' is *not* meant to be an existing user on the guest server, instead, it will be created *on the host server* during the installation of the Borg Server App. With borgserver_ynh apps you can't specify another repo path than ~/backup." + help = "Specify a local repository (`/mount/my_external_harddrive/backups`) or a remote repository (`ssh://USER@DOMAIN.TLD:PORT/~/backup`). If you plan to use a remote borgserver_ynh app : `USER` is *not* meant to be an existing user on the guest server, instead, it will be created *on the host server* during the installation of the Borg Server App. With borgserver_ynh apps you can't specify another repo path than `~/backup`." [main.general.ssh_public_key] ask.en = "Public key: {ssh_public_key}" @@ -33,9 +33,10 @@ services = [] bind = "/root/.ssh/id___APP___ed25519.pub" [main.general.on_calendar] - ask.en = "Frequency" + ask.en = "When at at which frequency should the backups be performed?" + ask.fr = "Quand et à quelle fréquence les sauvegardes doivent-elles être effectuées ?" type = "string" - help = "With which regular time schedule should the backups be performed? (see systemd OnCalendar format)" + help = "For example: `Monthly`, `Weekly`, `Daily` (=every day at midnight), `Hourly`, `Sat *-*-1..7 18:00:00` (=the first saturday of every month at 18:00), `4:00` (=every day at 4 AM), `5,17:00` (=every day at 5 AM and 5 PM). See the [systemd OnCalendar format for full syntax doc](https://wiki.archlinux.org/index.php/Systemd/Timers#Realtime_timer)" bind = "OnCalendar:/etc/systemd/system/__APP__.timer" [main.general.mailalert] @@ -47,7 +48,7 @@ services = [] help = "Alerts are sent to the first user of this server" [main.content] - name = "What should be backuped ?" + name = "What should be backuped?" optional = false [main.content.conf] @@ -67,11 +68,11 @@ services = [] type = "tags" help = "App list separated by comma. You can write 'all' to select all apps, even those installed after this borg app. You can also select all apps but some apps by writing 'exclude:' following by an app list separated by comma." -[advanced] -name = "Advanced" +[list] +name = "Last backups list" services = [] - [advanced.list] - name = "Last backups list" - [advanced.list.last_backups] + [list.list] + name = "" + [list.list.last_backups] ask.en = "" type = "markdown" diff --git a/doc/ADMIN.md b/doc/ADMIN.md index cfec498..45903e6 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -1,95 +1,14 @@ -## :warning: NB. : This doc is partially obsolete and should be reworked! :warning: - -## How to backup your server with this app? - -You want to backup a critical "guest" Server A onto a remote "host" Server B, you need: - -* Domain name of server B: `host.serverb` -* Name of the server B SSH user (to be created by `borgserver`) for connection from Server A: `borgservera` -* **Strong passphrase** to encrypt your backups on host Server B. And to **restore your backups**!! -* IDs of YunoHost apps you want to backup -* Regular time schedule for your backups, see below -* Install Borg Backup App (`borg`) on guest Server A -* Install Borg Server App (`borgserver`) on host Server B -* Save the passphrase in another place than your server. Without the passphrase, you won't be able to restore data. - -You should received an email after the first backup succeeded. - -### Set up Borg Backup App on guest Server A - -Firstly, set up the Borg Backup App (`borg`) on the guest Server A you want to backup: - -```bash -$ yunohost app install borg -In which borg repository location do you want to backup your files ?: user@host.serverb:/remote/repository -Provide a strong passphrase to encrypt your backups. No blank space: -Should Borg backup your YunoHost configuration? [yes | no] (default: yes): -Should Borg backup emails and user home directory? [yes | no] (default: yes): -Which apps should Borg backup ? (default: all): -With which regular time schedule should the backups be performed? (see systemd OnCalendar format) (default: Daily): -Do you want admin to receive mail notifications on backups ? [always | errors_only | never]: never -``` - -#### Syntax to define a backup time schedule - -You can schedule regular backups at specific time. Only one regular time schedule is possible for one `borg` instance, see below for workaround. Some examples: - -* Monthly : -* Weekly : -* Daily : Daily at midnight -* Hourly : Hourly o Clock -* Sat *-*-1..7 18:00:00 : The first saturday of every month at 18:00 -* 4:00 : Every day at 4 AM -* 5,17:00 : Every day at 5 AM and at 5 PM - -See here for more info : - -#### Information generated by Borg Backup - -At the end of the installation, the Borg Backup App (``borg``) displays the SSH public key and the SSH user to give to the person who has access to the host Server B and will set up Borg Server App. - -```text -You should now install the "Borg Server" app on host.serverb and fill questions like this: -User: servera -Public key: ssh-ed25519 AAAA[...] root@guest.servera -``` - -This information is also sent by email to the admin of guest Server A. -If you don't find the email and you don't see the message in the log bar you can find the SSH public key with this command: - -```bash -$ cat /root/.ssh/id_borg_ed25519.pub -ssh-ed25519 AAAA[...] root@guest.servera -``` - -### Set up Borg Server App on host Server B - -Secondly, set up the Borg Server App (``borgserver``) on the host Server B that will store your backups: - -```bash -$ yunohost app install borgserver -Indicate the ssh user to create: servera -Indicate the public key given by Borg Backup app (borg) setup: ssh-ed25519 AAAA[...] root@guest.servera -Indicate the storage quota: 5G -``` - -### Test the Borg Apps setup +## Testing that backup work as expected At this step your backup should run at the scheduled time. Note that the first backup can take very long, as much data has to be copied through ssh. Following backups are incremental: only newly generated data since last backup will be copied. -If you want to test correct Borg Apps setup before scheduled time, you can start a backup manually on guest Server A: +If you want to test correct Borg Apps setup before scheduled time, you can start a backup manually from the command line: ```bash systemctl start borg ``` -Next you can check presence of your backup repository on host Server B: - -```bash -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list servera@host.serverb:~/backup -``` - -You will need the passphrase to run ``borg`` commands on the backup repository created on the host Server B. +Once the backup completes, you can check that a backup is listed in the webadmin > Applications > Borg > 'Last backups list'. ## Check regularly your backup @@ -108,6 +27,9 @@ borg list ./::ARCHIVE_NAME | grep dump.sql * Be sure to have your passphrase available even if your server is completely broken + + + ## How to restore a complete system *For infos on restoring process, check [this yunohost forum thread](https://forum.yunohost.org/t/restoring-whole-yunohost-from-borg-backups/12705/3) and [that one](https://forum.yunohost.org/t/how-to-properly-backup-and-restore/12583/3), also [using Borg with sshkeys](https://thisiscasperslife.wordpress.com/2017/11/28/using-borg-backup-across-ssh-with-sshkeys/), the [`borg extract` documentation](https://borgbackup.readthedocs.io/en/stable/usage/extract.html), and this [general tutorial on Borg Backup](https://practical-admin.com/blog/backups-using-borg/).* @@ -122,11 +44,11 @@ In the following explanations: ### Overview -The idea here, if you need to restore a whole yunohost system is: +If you need to restore a whole yunohost system: -1. Install a new Debian VM -2. Install YunoHost in it the usual way -3. Go through YunoHost postinstall (parameters you will supply are not crucial, as they will be replaced by the restore) +1. Setup a new Debian system +2. Install YunoHost the usual way +3. Go through YunoHost's postinstall (parameters you will supply are not crucial, as they will be replaced by the restore) 4. Install Borg 5. Setup `rem` to accept ssh connections from `yuno` 6. Use Borg to import backups from `rem` to `yuno` @@ -216,32 +138,3 @@ For that, remove the "dummy" Borg you installed to do the restoration, and resto sudo yunohost app remove borg sudo yunohost backup restore auto_borg_XX_XX_XX_XX:XX --apps ``` - -## Tips - -### Edit the list of YunoHost apps to backup - -`yunohost app setting borg apps -v "nextcloud,wordpress"` - -### Other usefull borg commands - -[Get the storage space used by the backup repository on the host server](https://borgbackup.readthedocs.io/en/stable/usage/info.html) -`borg info /home/servera/backup` - -### Backup YunoHost apps with different criticallity levels - -If you want to backup your guest server: - -* with different YunoHost apps -* at different regular time schedule -* on different host servers - -Then you can set up multiple instances of the Borg Apps on same servers. -For instance: - -* Borg Backup instance ``borg``: backup nextcloud daily on host Server B -* Borg Backup instance ``borg__2``: backup all other YunoHost apps weekly on host Server C - -### Settings location - -Settings of apps are in /etc/yunohost/apps/*/settings.yml, so are the settings for borg_ynh as well. Be careful though to not savagely manually edit them if you don't know what you're doing. diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 806909c..67204f8 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,3 +1,16 @@ -A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. +It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. + +### Features + +- Backup on a remote machine, in comination with the [borg server app](https://apps.yunohost.org/app/borgserver) +- ... or on a [commercial borg service](https://www.borgbackup.org/support/commercial.html) +- Backups are encrypted (the remote server can't read the content) and deduplicated (optimize space) +- Backups are ran automatically, you can choose when and at which frequency +- You can choose what apps are backuped +- Receive email alerts if the backup fails (the [borg server app](https://apps.yunohost.org/app/borgserver) also checks that new content arrives and send an email to your friend otherwise) + +### Install procedure + +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 0decff5..3c687a1 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -9,4 +9,4 @@ Or if you want to use command-line: `yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh -a "ssh_user=__SSH_USER__&public_key=__PUBLIC_KEY__"` -If you facing an issue or want to improve this app, please open a new issue in this project: +NB: the SSH user is not meant to pre-exist on the server on which borgserver is installed! diff --git a/manifest.toml b/manifest.toml index ece5305..90a071d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -31,15 +31,15 @@ ram.runtime = "50M" [install.repository] ask.en = "In which borg repository location do you want to backup your files ?" ask.fr = "Dans quel repo borg souhaitez-vous sauvegarder vos fichiers ?" - help.en = "Specify a local repository like /mount/my_external_harddrive/backups or a remote repository using this format: ssh://USER@DOMAIN.TLD:PORT/~/backup . If you plan to use borgserver_ynh app : 'USER' is *not* meant to be an existing user on the guest server, instead, it will be created *on the host server* during the installation of the Borg Server App. With borgserver_ynh apps you can't specify another repo path than ~/backup." + help.en = "Specify a local repository (`/mount/my_external_harddrive/backups`) or a remote repository (`ssh://USER@DOMAIN.TLD:PORT/~/backup`). If you plan to use a remote borgserver_ynh app : `USER` is *not* meant to be an existing user on the guest server, instead, it will be created *on the host server* during the installation of the Borg Server App. With borgserver_ynh apps you can't specify another repo path than `~/backup`." type = "string" example = "ssh://john@serverb.tld:22/~/backup" [install.passphrase] ask.en = "Provide a strong passphrase to encrypt your backups. No blank space" ask.fr = "Indiquez une phrase de passe forte pour chiffrer vos sauvegardes. Sans espaces" - help.en = "Keep it safe! ...if you want to be able to restore. Do not communicate it to host Server holder or anyone else." - help.fr = "Gardez-la précieusement! ...si vous voulez pouvoir restaurer. Ne donnez pas la clé au possesseur du Serveur distant, ni personne." + help.en = "Keep it safe! There will be **no way** to restore your backup if you lose it. Do not communicate it to the remote host server holder, or anyone else." + help.fr = "Gardez-la précieusement ! Il sera impossible de restaurer vos sauvegardes sans celle-ci. Ne donnez pas cette clé à la personne qui gère le serveur distant - où à n'importe qui d'ailleurs." type = "password" [install.conf] @@ -49,8 +49,8 @@ ram.runtime = "50M" default = true [install.data] - ask.en = "Should Borg backup emails and user home directory?" - ask.fr = "Borg doit-il sauvegarder les mails et les répertoires des utilisateurs ?" + ask.en = "Should Borg backup emails and user home directories?" + ask.fr = "Borg doit-il sauvegarder les mails et les répertoires (home) des utilisateurs ?" type = "boolean" default = true @@ -63,10 +63,10 @@ ram.runtime = "50M" default = "all" [install.on_calendar] - ask.en = "With which regular time schedule should the backups be performed? (see systemd OnCalendar format)" - ask.fr = "À quelle fréquence les sauvegardes doivent-elles être effectuées ? (voir le format OnCalendar de systemd)" + ask.en = "When at at which frequency should the backups be performed?" + ask.fr = "Quand et à quelle fréquence les sauvegardes doivent-elles être effectuées ?" type = "string" - example = "Monthly or Weekly or Daily or Hourly or 4:00 or 5,17:00 or Sat --1..7 18:00:00" + help = "For example: `Monthly`, `Weekly`, `Daily` (=every day at midnight), `Hourly`, `Sat *-*-1..7 18:00:00` (=the first saturday of every month at 18:00), `4:00` (=every day at 4 AM), `5,17:00` (=every day at 5 AM and 5 PM). See the [systemd OnCalendar format for full syntax doc](https://wiki.archlinux.org/index.php/Systemd/Timers#Realtime_timer)" default = "Daily" [install.mailalert] @@ -85,13 +85,12 @@ ram.runtime = "50M" packages = [ "python3-pip", "python3-dev", - "libacl1-dev", - "libssl-dev", - "liblz4-dev", "python3-jinja2", "python3-setuptools", "python3-venv", - "virtualenv", + "libacl1-dev", + "libssl-dev", + "liblz4-dev", "libfuse3-dev", "pkg-config", ] From 3f9a00861d37cc5f4d6978c0359d01efa5f94625 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 3 May 2024 13:44:04 +0000 Subject: [PATCH 21/35] Auto-update READMEs --- README.md | 17 +++++++++++++++-- README_eu.md | 17 +++++++++++++++-- README_fr.md | 17 +++++++++++++++-- README_gl.md | 17 +++++++++++++++-- README_zh_Hans.md | 17 +++++++++++++++-- 5 files changed, 75 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b767db2..81f53d9 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,22 @@ It shall NOT be edited by hand. ## Overview -A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. +It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. + +### Features + +- Backup on a remote machine, in comination with the [borg server app](https://apps.yunohost.org/app/borgserver) +- ... or on a [commercial borg service](https://www.borgbackup.org/support/commercial.html) +- Backups are encrypted (the remote server can't read the content) and deduplicated (optimize space) +- Backups are ran automatically, you can choose when and at which frequency +- You can choose what apps are backuped +- Receive email alerts if the backup fails (the [borg server app](https://apps.yunohost.org/app/borgserver) also checks that new content arrives and send an email to your friend otherwise) + +### Install procedure + +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **Shipped version:** 1.2.8~ynh1 diff --git a/README_eu.md b/README_eu.md index 0796b1a..f4311d8 100644 --- a/README_eu.md +++ b/README_eu.md @@ -16,9 +16,22 @@ EZ editatu eskuz. ## Aurreikuspena -A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. +It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. + +### Features + +- Backup on a remote machine, in comination with the [borg server app](https://apps.yunohost.org/app/borgserver) +- ... or on a [commercial borg service](https://www.borgbackup.org/support/commercial.html) +- Backups are encrypted (the remote server can't read the content) and deduplicated (optimize space) +- Backups are ran automatically, you can choose when and at which frequency +- You can choose what apps are backuped +- Receive email alerts if the backup fails (the [borg server app](https://apps.yunohost.org/app/borgserver) also checks that new content arrives and send an email to your friend otherwise) + +### Install procedure + +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **Paketatutako bertsioa:** 1.2.8~ynh1 diff --git a/README_fr.md b/README_fr.md index 1d6b3a0..fefc974 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,9 +16,22 @@ Il NE doit PAS être modifié à la main. ## Vue d’ensemble -A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. +It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. + +### Features + +- Backup on a remote machine, in comination with the [borg server app](https://apps.yunohost.org/app/borgserver) +- ... or on a [commercial borg service](https://www.borgbackup.org/support/commercial.html) +- Backups are encrypted (the remote server can't read the content) and deduplicated (optimize space) +- Backups are ran automatically, you can choose when and at which frequency +- You can choose what apps are backuped +- Receive email alerts if the backup fails (the [borg server app](https://apps.yunohost.org/app/borgserver) also checks that new content arrives and send an email to your friend otherwise) + +### Install procedure + +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **Version incluse :** 1.2.8~ynh1 diff --git a/README_gl.md b/README_gl.md index 28a3eaf..7a76156 100644 --- a/README_gl.md +++ b/README_gl.md @@ -16,9 +16,22 @@ NON debe editarse manualmente. ## Vista xeral -A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. +It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. + +### Features + +- Backup on a remote machine, in comination with the [borg server app](https://apps.yunohost.org/app/borgserver) +- ... or on a [commercial borg service](https://www.borgbackup.org/support/commercial.html) +- Backups are encrypted (the remote server can't read the content) and deduplicated (optimize space) +- Backups are ran automatically, you can choose when and at which frequency +- You can choose what apps are backuped +- Receive email alerts if the backup fails (the [borg server app](https://apps.yunohost.org/app/borgserver) also checks that new content arrives and send an email to your friend otherwise) + +### Install procedure + +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **Versión proporcionada:** 1.2.8~ynh1 diff --git a/README_zh_Hans.md b/README_zh_Hans.md index de8ef60..ff443d5 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -16,9 +16,22 @@ ## 概况 -A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server. +It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. + +### Features + +- Backup on a remote machine, in comination with the [borg server app](https://apps.yunohost.org/app/borgserver) +- ... or on a [commercial borg service](https://www.borgbackup.org/support/commercial.html) +- Backups are encrypted (the remote server can't read the content) and deduplicated (optimize space) +- Backups are ran automatically, you can choose when and at which frequency +- You can choose what apps are backuped +- Receive email alerts if the backup fails (the [borg server app](https://apps.yunohost.org/app/borgserver) also checks that new content arrives and send an email to your friend otherwise) + +### Install procedure + +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **分发版本:** 1.2.8~ynh1 From 2c20d67d51c3b154887c35e0c5f542b04f3f634f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 3 May 2024 16:06:22 +0200 Subject: [PATCH 22/35] Rename backup-with-$app to backup-with-borg now that it's in install_dir --- conf/sudoer | 2 +- conf/systemd.service | 2 +- scripts/install | 6 +++--- scripts/upgrade | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conf/sudoer b/conf/sudoer index fec3569..b6e756a 100644 --- a/conf/sudoer +++ b/conf/sudoer @@ -1 +1 @@ -__APP__ ALL=(root) NOPASSWD: __INSTALL_DIR__/backup-with-__APP__, __INSTALL_DIR__/venv/bin/borg, /usr/bin/yunohost backup create *, /usr/bin/yunohost app setting *, /bin/ls, /usr/bin/test +__APP__ ALL=(root) NOPASSWD: __INSTALL_DIR__/backup-with-borg, __INSTALL_DIR__/venv/bin/borg, /usr/bin/yunohost backup create *, /usr/bin/yunohost app setting *, /bin/ls, /usr/bin/test diff --git a/conf/systemd.service b/conf/systemd.service index 87c332f..636ca96 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -4,7 +4,7 @@ After=network.target [Service] Type=oneshot -ExecStart=/usr/bin/sudo __INSTALL_DIR__/backup-with-__APP__ __APP__ +ExecStart=/usr/bin/sudo __INSTALL_DIR__/backup-with-borg __APP__ User=__APP__ Group=__APP__ diff --git a/scripts/install b/scripts/install index bf707a0..e600c07 100755 --- a/scripts/install +++ b/scripts/install @@ -61,9 +61,9 @@ mkdir -p /usr/share/yunohost/backup_method ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app" chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app" -ynh_add_config --template="backup-with-borg" --destination="$install_dir/backup-with-$app" -chmod u+x "$install_dir/backup-with-$app" -chown "$app:$app" "$install_dir/backup-with-$app" +ynh_add_config --template="backup-with-borg" --destination="$install_dir/backup-with-borg" +chmod u+x "$install_dir/backup-with-borg" +chown "$app:$app" "$install_dir/backup-with-borg" ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app" chown root:root "/etc/sudoers.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 174271d..93a6039 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,7 +58,7 @@ fi if [ -d /opt/borg-env ]; then ynh_secure_remove --file="/opt/borg-env" ynh_secure_remove --file="/usr/local/bin/borg" - ynh_secure_remove --file="/usr/local/bin/backup-with-$app" + ynh_secure_remove --file="/usr/local/bin/backup-with-borg" fi #================================================= @@ -86,9 +86,9 @@ mkdir -p /usr/share/yunohost/backup_method ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app" chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app" -ynh_add_config --template="backup-with-borg" --destination="$install_dir/backup-with-$app" -chmod u+x "$install_dir/backup-with-$app" -chown "$app:$app" "$install_dir/backup-with-$app" +ynh_add_config --template="backup-with-borg" --destination="$install_dir/backup-with-borg" +chmod u+x "$install_dir/backup-with-borg" +chown "$app:$app" "$install_dir/backup-with-borg" ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app" chown root:root "/etc/sudoers.d/$app" From ac236f400a7bc613c7892b12c00463da01de695c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 3 May 2024 16:44:12 +0200 Subject: [PATCH 23/35] Split the 'full restore' doc into a separate admin page --- doc/ADMIN.md | 118 ++------------------------------------------ doc/FULL_RESTORE.md | 109 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 115 deletions(-) create mode 100644 doc/FULL_RESTORE.md diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 45903e6..c74d567 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -16,8 +16,8 @@ If you want to be sure to be able to restore your server, you should try to rest You should at least: -* Keep your apps up to date (if apps are too old, they could be difficult to restore on a more recent recent version) -* Check regularly the presence of `info.json` and `db.sql` or `dump.sql` in your apps archives +- Keep your apps up to date (if apps are too old, they could be difficult to restore on a more recent recent version) +- Check regularly the presence of `info.json` and `db.sql` or `dump.sql` in your apps archives ```bash borg list ./::ARCHIVE_NAME | grep info.json @@ -25,116 +25,4 @@ borg list ./::ARCHIVE_NAME | grep db.sql borg list ./::ARCHIVE_NAME | grep dump.sql ``` -* Be sure to have your passphrase available even if your server is completely broken - - - - -## How to restore a complete system - -*For infos on restoring process, check [this yunohost forum thread](https://forum.yunohost.org/t/restoring-whole-yunohost-from-borg-backups/12705/3) and [that one](https://forum.yunohost.org/t/how-to-properly-backup-and-restore/12583/3), also [using Borg with sshkeys](https://thisiscasperslife.wordpress.com/2017/11/28/using-borg-backup-across-ssh-with-sshkeys/), the [`borg extract` documentation](https://borgbackup.readthedocs.io/en/stable/usage/extract.html), and this [general tutorial on Borg Backup](https://practical-admin.com/blog/backups-using-borg/).* - -In the following explanations: - -* the server to backup/restore will be called: `yuno` -* the remote server that receives and store the back will be called: `rem` -* `rem` is accessible at the domain `rem.tld` -* the remote user on `rem` which owns the Borg backups will be called `yurem` -* backup files will be stored in `rem` in the directory: `/home/yurem/backup` - -### Overview - -If you need to restore a whole yunohost system: - -1. Setup a new Debian system -2. Install YunoHost the usual way -3. Go through YunoHost's postinstall (parameters you will supply are not crucial, as they will be replaced by the restore) -4. Install Borg -5. Setup `rem` to accept ssh connections from `yuno` -6. Use Borg to import backups from `rem` to `yuno` -7. Restore Borg backups with the `yunohost backup restore` command, first config, then data, then each app one at a time -8. Remove the Borg app and restore it - -### Make it possible for `yuno` to connect to `rem` with Borg - -At this stage, we will assume that `yuno` is a freshly installed YunoHost (based on Buster in my case). You should also have performed the YunoHost postinstall. - -If you don't want to restore the whole system, just some apps, you can skip some of the steps below. - -#### Install the Borg YunoHost app in `yuno` - -The idea here is just to install Borg, not in order to create backups, but only to use Borg commands to import remote backups. - -So for example, you can install it doing the following: - -```bash -sudo yunohost app install borg -a "server=rem.tld&ssh_user=yurem&conf=0&data=0&apps=hextris&on_calendar=2:30" -``` - -#### Make sure that `rem` accepts ssh connections from `yuno` - -In `yuno` you will need to get the ssh key that borg just created while installing: `sudo cat /root/.ssh/id_borg_ed25519.pub`, copy it to clipboard. - -Connect via ssh to `rem`, go to `/home/yurem/.ssh/authorized_keys`, and past the Borg public key you got at previous step. - -Now to make sure this worked, you can try to SSH from `yuno` to `rem`. -In `yuno` : `ssh -i /root/.ssh/id_borg_ed25519 yurem@rem.tld` . If you can get into `rem` , without it prompting for a password, then you're good to continue :) - -### Restore backups to `yuno` - -⚠️ For the commands in the following section to work, you will need to be root in `yuno` (you can become root running `sudo su`). - -⚠️ Restoration of backups can take quite a while, you'd better do them in a separate process, so that it doesn't stop if your terminal session gets closed. For this, you can for example use [tmux](https://www.howtogeek.com/671422/how-to-use-tmux-on-linux-and-why-its-better-than-screen/). - -In `yuno` now, you should be able to list backups in `rem` with the following command: - -```bash -SRV=yurem@rem.tld:/home/yurem/backup -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list $SRV -``` - -You can then reimport one to `yuno` with: - -```bash -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg export-tar $SRV::auto_BACKUP_NAME /home/yunohost.backup/archives/auto_BACKUP_NAME.tar.gz -``` - -And then restore the archive in `yuno` with: - -```bash -yunohost backup restore auto_BACKUP_NAME --system # for config and data backups -yunohost backup restore auto_BACKUP_NAME --apps # for other backups (=apps) -``` - -### And Nextcloud? It's super heavy!! - -For Nextcloud, the best is probably to reimport the backup without the data. And to import the data manually. - -For that, you can do the following (as root): - -```bash -SRV=yurem@rem.tld:/home/yurem/backup - -# export the app without data -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg export-tar -e apps/nextcloud/backup/home/yunohost.app $SRV::auto_nextcloud_XX_XX_XX_XX:XX /home/yunohost.backup/archives/auto_nextcloud_XX_XX_XX_XX:XX.tar.gz - -# extract the data from the backup to the nextcloud folder -cd /home/yunohost.app/nextcloud -BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg extract $SRV::auto_nextcloud_XX_XX_XX_XX:XX apps/nextcloud/backup/home/yunohost.app/nextcloud/ -mv apps/nextcloud/backup/home/yunohost.app/nextcloud/data data -rm -r apps - -# now you can simply restore nextcloud app -yunohost backup restore auto_nextcloud_XX_XX_XX_XX:XX --apps -``` - -### Restore Borg - -Once you've restored the whole system, you will probably want to restore the Borg app as well. - -For that, remove the "dummy" Borg you installed to do the restoration, and restore Borg the same ways as for other apps: - -```bash -sudo yunohost app remove borg -sudo yunohost backup restore auto_borg_XX_XX_XX_XX:XX --apps -``` +- Be sure to have your passphrase available even if your server is completely broken diff --git a/doc/FULL_RESTORE.md b/doc/FULL_RESTORE.md new file mode 100644 index 0000000..5b1ed86 --- /dev/null +++ b/doc/FULL_RESTORE.md @@ -0,0 +1,109 @@ + +This is a copy-paste of the discussion at . See also , the [`borg extract` documentation](https://borgbackup.readthedocs.io/en/stable/usage/extract.html), and this [general tutorial on Borg Backup](https://practical-admin.com/blog/backups-using-borg/).* + +## How to restore a complete system + +In the following explanations: + +* the server to backup/restore will be called: `yuno` +* the remote server that receives and store the back will be called: `rem` +* `rem` is accessible at the domain `rem.tld` +* the remote user on `rem` which owns the Borg backups will be called `yurem` +* backup files will be stored in `rem` in the directory: `/home/yurem/backup` + +### Overview + +If you need to restore a whole yunohost system: + +1. Setup a new Debian system +2. Install YunoHost the usual way +3. Go through YunoHost's postinstall (parameters you will supply are not crucial, as they will be replaced by the restore) +4. Install Borg +5. Setup `rem` to accept ssh connections from `yuno` +6. Use Borg to import backups from `rem` to `yuno` +7. Restore Borg backups with the `yunohost backup restore` command, first config, then data, then each app one at a time +8. Remove the Borg app and restore it + +### Make it possible for `yuno` to connect to `rem` with Borg + +At this stage, we will assume that `yuno` is a freshly installed YunoHost (based on Buster in my case). You should also have performed the YunoHost postinstall. + +If you don't want to restore the whole system, just some apps, you can skip some of the steps below. + +#### Install the Borg YunoHost app in `yuno` + +The idea here is just to install Borg, not in order to create backups, but only to use Borg commands to import remote backups. + +So for example, you can install it doing the following: + +```bash +sudo yunohost app install borg -a "server=rem.tld&ssh_user=yurem&conf=0&data=0&apps=hextris&on_calendar=2:30" +``` + +#### Make sure that `rem` accepts ssh connections from `yuno` + +In `yuno` you will need to get the ssh key that borg just created while installing: `sudo cat /root/.ssh/id_borg_ed25519.pub`, copy it to clipboard. + +Connect via ssh to `rem`, go to `/home/yurem/.ssh/authorized_keys`, and past the Borg public key you got at previous step. + +Now to make sure this worked, you can try to SSH from `yuno` to `rem`. +In `yuno` : `ssh -i /root/.ssh/id_borg_ed25519 yurem@rem.tld` . If you can get into `rem` , without it prompting for a password, then you're good to continue :) + +### Restore backups to `yuno` + +⚠️ For the commands in the following section to work, you will need to be root in `yuno` (you can become root running `sudo su`). + +⚠️ Restoration of backups can take quite a while, you'd better do them in a separate process, so that it doesn't stop if your terminal session gets closed. For this, you can for example use [tmux](https://www.howtogeek.com/671422/how-to-use-tmux-on-linux-and-why-its-better-than-screen/). + +In `yuno` now, you should be able to list backups in `rem` with the following command: + +```bash +SRV=yurem@rem.tld:/home/yurem/backup +BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg list $SRV +``` + +You can then reimport one to `yuno` with: + +```bash +BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg export-tar $SRV::auto_BACKUP_NAME /home/yunohost.backup/archives/auto_BACKUP_NAME.tar.gz +``` + +And then restore the archive in `yuno` with: + +```bash +yunohost backup restore auto_BACKUP_NAME --system # for config and data backups +yunohost backup restore auto_BACKUP_NAME --apps # for other backups (=apps) +``` + +### And Nextcloud? It's super heavy!! + +For Nextcloud, the best is probably to reimport the backup without the data. And to import the data manually. + +For that, you can do the following (as root): + +```bash +SRV=yurem@rem.tld:/home/yurem/backup + +# export the app without data +BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg export-tar -e apps/nextcloud/backup/home/yunohost.app $SRV::auto_nextcloud_XX_XX_XX_XX:XX /home/yunohost.backup/archives/auto_nextcloud_XX_XX_XX_XX:XX.tar.gz + +# extract the data from the backup to the nextcloud folder +cd /home/yunohost.app/nextcloud +BORG_RSH="ssh -i /root/.ssh/id_borg_ed25519 -oStrictHostKeyChecking=yes " borg extract $SRV::auto_nextcloud_XX_XX_XX_XX:XX apps/nextcloud/backup/home/yunohost.app/nextcloud/ +mv apps/nextcloud/backup/home/yunohost.app/nextcloud/data data +rm -r apps + +# now you can simply restore nextcloud app +yunohost backup restore auto_nextcloud_XX_XX_XX_XX:XX --apps +``` + +### Restore Borg + +Once you've restored the whole system, you will probably want to restore the Borg app as well. + +For that, remove the "dummy" Borg you installed to do the restoration, and restore Borg the same ways as for other apps: + +```bash +sudo yunohost app remove borg +sudo yunohost backup restore auto_borg_XX_XX_XX_XX:XX --apps +``` From aa3e0c4eae27213c79c242f5cdff1da533c8dff2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 3 May 2024 16:57:29 +0200 Subject: [PATCH 24/35] doc: misc typo, smoothing --- doc/DESCRIPTION.md | 4 ++-- doc/POST_INSTALL.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 67204f8..07e01d2 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,6 +1,6 @@ A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. +This app is the "client" part, meant to be installed on the server to be backed up. It works in combination with the [borg server app](https://apps.yunohost.org/app/borgserver) installed on a diffent machine. ### Features @@ -13,4 +13,4 @@ It works This is the Borg Backup App to be installed on a server to backup. It w ### Install procedure -Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, at the end of the install of `borg_ynh`, you will be provided with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 3c687a1..9b16f91 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,11 +1,11 @@ You should check out the admin documentation of this app after installation for more info! -If you selected a remote borg server as backup target, you should now install the "Borg Server" app on __SERVER__ and with the following credentials: +If you selected a remote borg server as backup target, you should now install the "Borg Server" app on `__SERVER__` and with the following credentials (you may need to send this to your friend): - User: `__SSH_USER__` - Public key: `__PUBLIC_KEY__` -Or if you want to use command-line: +Or directly using command line: `yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh -a "ssh_user=__SSH_USER__&public_key=__PUBLIC_KEY__"` From 616f700c971bf0e544741abd596a865ec7df4cad Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 3 May 2024 14:57:37 +0000 Subject: [PATCH 25/35] Auto-update READMEs --- README.md | 4 ++-- README_eu.md | 4 ++-- README_fr.md | 4 ++-- README_gl.md | 4 ++-- README_zh_Hans.md | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 81f53d9..b8c919c 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ It shall NOT be edited by hand. A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. +This app is the "client" part, meant to be installed on the server to be backed up. It works in combination with the [borg server app](https://apps.yunohost.org/app/borgserver) installed on a diffent machine. ### Features @@ -31,7 +31,7 @@ It works This is the Borg Backup App to be installed on a server to backup. It w ### Install procedure -Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, at the end of the install of `borg_ynh`, you will be provided with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **Shipped version:** 1.2.8~ynh1 diff --git a/README_eu.md b/README_eu.md index f4311d8..4ca632f 100644 --- a/README_eu.md +++ b/README_eu.md @@ -18,7 +18,7 @@ EZ editatu eskuz. A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. +This app is the "client" part, meant to be installed on the server to be backed up. It works in combination with the [borg server app](https://apps.yunohost.org/app/borgserver) installed on a diffent machine. ### Features @@ -31,7 +31,7 @@ It works This is the Borg Backup App to be installed on a server to backup. It w ### Install procedure -Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, at the end of the install of `borg_ynh`, you will be provided with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **Paketatutako bertsioa:** 1.2.8~ynh1 diff --git a/README_fr.md b/README_fr.md index fefc974..494ac91 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Il NE doit PAS être modifié à la main. A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. +This app is the "client" part, meant to be installed on the server to be backed up. It works in combination with the [borg server app](https://apps.yunohost.org/app/borgserver) installed on a diffent machine. ### Features @@ -31,7 +31,7 @@ It works This is the Borg Backup App to be installed on a server to backup. It w ### Install procedure -Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, at the end of the install of `borg_ynh`, you will be provided with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **Version incluse :** 1.2.8~ynh1 diff --git a/README_gl.md b/README_gl.md index 7a76156..8b4dc22 100644 --- a/README_gl.md +++ b/README_gl.md @@ -18,7 +18,7 @@ NON debe editarse manualmente. A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. +This app is the "client" part, meant to be installed on the server to be backed up. It works in combination with the [borg server app](https://apps.yunohost.org/app/borgserver) installed on a diffent machine. ### Features @@ -31,7 +31,7 @@ It works This is the Borg Backup App to be installed on a server to backup. It w ### Install procedure -Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, at the end of the install of `borg_ynh`, you will be provided with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **Versión proporcionada:** 1.2.8~ynh1 diff --git a/README_zh_Hans.md b/README_zh_Hans.md index ff443d5..82f1c76 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -18,7 +18,7 @@ A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). -It works This is the Borg Backup App to be installed on a server to backup. It works in combination with the [Borg Server App](https://apps.yunohost.org/app/borgserver) installed on a host server. +This app is the "client" part, meant to be installed on the server to be backed up. It works in combination with the [borg server app](https://apps.yunohost.org/app/borgserver) installed on a diffent machine. ### Features @@ -31,7 +31,7 @@ It works This is the Borg Backup App to be installed on a server to backup. It w ### Install procedure -Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, after the install of `borg_ynh`, a message should be displayed with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, at the end of the install of `borg_ynh`, you will be provided with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. **分发版本:** 1.2.8~ynh1 From 52a8e3e2c63670dd6a41452ed6e4292c84074721 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 3 May 2024 17:01:53 +0200 Subject: [PATCH 26/35] Better short description idk --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 90a071d..b91c260 100644 --- a/manifest.toml +++ b/manifest.toml @@ -4,8 +4,8 @@ packaging_format = 2 id = "borg" name = "Borg Backup" -description.en = "Backup your server on a host server using Borg" -description.fr = "Sauvegardez votre serveur sur un serveur distant avec Borg" +description.en = "Regularly create deduplicated, encrypted backups sent to another server using Borg" +description.fr = "Créez régulièrement des sauvegardes dédupliquées et chiffées envoyées sur un autre serveur à l'aide de Borg" version = "1.2.8~ynh1" From 5e2f1e79105729c548317ca3914fa64108986f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 4 May 2024 17:26:27 +0200 Subject: [PATCH 27/35] Fix backup_method: global borg executable is now in venv --- conf/backup_method | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/conf/backup_method b/conf/backup_method index e99dcfc..de6cb58 100644 --- a/conf/backup_method +++ b/conf/backup_method @@ -1,6 +1,8 @@ #!/bin/bash set -eo pipefail +source __INSTALL_DIR__/venv/bin/activate + app="${0#"./05-"}" app="${app%"_app"}" @@ -22,7 +24,7 @@ log_with_timestamp() { } do_backup() { - + export BORG_PASSPHRASE export BORG_RSH export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes @@ -50,13 +52,13 @@ This is an automated message from your beloved YunoHost server." | /usr/bin/mail borg create "$repo::_${name}-${current_date}" ./ 2>&1 >/dev/null | log_with_timestamp popd - # About thi _20 it's a crazy fix to avoid pruning wordpress__2 + # About thi _20 it's a crazy fix to avoid pruning wordpress__2 # if you prune wordpress borg prune "$repo" -P "_${name}-" --keep-hourly 2 --keep-daily=7 --keep-weekly=8 --keep-monthly=12 2>&1 >/dev/null | log_with_timestamp - + # Prune legacy archive name without error on wordpress/wordpress__2 borg prune "$repo" -P "${name}_" --keep-within 2m --keep-monthly=12 2>&1 >/dev/null | log_with_timestamp - + # We prune potential manual backup older than 1 year borg prune "$repo" --keep-within 1y 2>&1 >/dev/null | log_with_timestamp } From 75c27652117f2df2b31ca881c48d966f939a3357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 4 May 2024 17:30:25 +0200 Subject: [PATCH 28/35] backup_method coding style --- conf/backup_method | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/conf/backup_method b/conf/backup_method index de6cb58..d172cc2 100644 --- a/conf/backup_method +++ b/conf/backup_method @@ -1,13 +1,12 @@ -#!/bin/bash +#!/usr/bin/env bash +set -Eeuo pipefail -set -eo pipefail -source __INSTALL_DIR__/venv/bin/activate +source "__INSTALL_DIR__/venv/bin/activate" +app="__APP__" -app="${0#"./05-"}" -app="${app%"_app"}" +BORG_PASSPHRASE="$(yunohost app setting "$app" passphrase)" +repo="$(yunohost app setting "$app" repository)" #$4 -BORG_PASSPHRASE="$(yunohost app setting $app passphrase)" -repo="$(yunohost app setting $app repository)" #$4 if ssh-keygen -F "__SERVER__" >/dev/null ; then BORG_RSH="ssh -i /root/.ssh/id_${app}_ed25519 -oStrictHostKeyChecking=yes " else @@ -20,11 +19,10 @@ do_need_mount() { LOGFILE=/var/log/backup_borg.err log_with_timestamp() { - sed -e "s/^/[$(date +"%Y-%m-%d_%H:%M:%S")] /" | tee -a $LOGFILE + sed -e "s/^/[$(date +"%Y-%m-%d_%H:%M:%S")] /" | tee -a $LOGFILE } do_backup() { - export BORG_PASSPHRASE export BORG_RSH export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes @@ -37,11 +35,11 @@ do_backup() { pushd "$work_dir" set +e if borg init -e repokey "$repo" ; then - #human_size=`echo $size | awk '{ suffix=" KMGT"; for(i=1; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'` - # Speed in Kbps - #speed=1000 - #evaluated_time=$(($size / ($speed * 1000 / 8) / 3600)) - echo "Hello, + # human_size=`echo $size | awk '{ suffix=" KMGT"; for(i=1; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'` + # Speed in Kbps + # speed=1000 + # evaluated_time=$(($size / ($speed * 1000 / 8) / 3600)) + echo "Hello, Your first backup on $repo is starting. @@ -88,7 +86,7 @@ case "$1" in do_backup "$work_dir" "$name" "$repo" "$size" "$description" ;; mount) - do_mount + do_mount "$work_dir" "$name" "$repo" "$size" "$description" ;; *) echo "hook called with unknown argument \`$1'" >&2 From 97d578d12751a239cf69bbff9ebcf6f36cb88df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 4 May 2024 17:35:07 +0200 Subject: [PATCH 29/35] Coding style --- conf/backup-with-borg | 60 ++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/conf/backup-with-borg b/conf/backup-with-borg index 33aaf1f..0912891 100644 --- a/conf/backup-with-borg +++ b/conf/backup-with-borg @@ -1,6 +1,5 @@ -#!/bin/bash - -# We don't stop the script on errors cause we want to backup all data we could backuped +#!/usr/bin/env bash +# We don't stop the script on errors cause we want to backup all data we could backed up #set -eu borg_id=$1 @@ -9,56 +8,53 @@ current_date=$(date +"%y%m%d_%H%M") log_file="/var/log/${borg_id}/${current_date}.log" err_file="/var/log/${borg_id}/${current_date}.err" mkdir -p "/var/log/${borg_id}" -if [ -z "$borg_id" ] -then +if [ -z "$borg_id" ]; then echo "This script expects a borg app id as first argument" >&2 exit 1 fi filter_hooks() { - sudo ls /usr/share/yunohost/hooks/backup/ /etc/yunohost/hooks.d/backup/ | grep "\-$1_" | cut -d"-" -f2 | uniq 2>> $err_file + sudo ls /usr/share/yunohost/hooks/backup/ /etc/yunohost/hooks.d/backup/ | grep "\-$1_" | cut -d"-" -f2 | uniq 2>> "$err_file" } fail_if_partially_failed() { grep Skipped|Error } -sudo yunohost app setting ${borg_id} last_run -v "${current_date}" -sudo yunohost app setting ${borg_id} state -v "ongoing" +sudo yunohost app setting "${borg_id}" last_run -v "${current_date}" +sudo yunohost app setting "${borg_id}" state -v "ongoing" # Backup system part conf -conf=$(sudo yunohost app setting ${borg_id} conf) -if [[ "$conf" = "1" ]] -then - if ! sudo yunohost backup create -n auto_conf --method ${borg_id}_app --system $(filter_hooks conf) 2>> $err_file >> $log_file ; then +conf=$(sudo yunohost app setting "${borg_id}" conf) +if [[ "$conf" = "1" ]]; then + if ! sudo yunohost backup create -n auto_conf --method "${borg_id}_app" --system $(filter_hooks conf) 2>> "$err_file" >> "$log_file" ; then errors+="\nThe backup miserably failed to backup system configurations." fi fi # Backup system data -data=$(sudo yunohost app setting ${borg_id} data) -if [[ "$data" = "1" ]] -then - if ! sudo yunohost backup create -n auto_data --method ${borg_id}_app --system $(filter_hooks data) 2>> $err_file >> $log_file ; then +data=$(sudo yunohost app setting "${borg_id}" data) +if [[ "$data" = "1" ]]; then + if ! sudo yunohost backup create -n auto_data --method "${borg_id}_app" --system $(filter_hooks data) 2>> "$err_file" >> "$log_file" ; then errors+="\nThe backup miserably failed to backup system data." fi fi # Backup all apps independently -apps=$(sudo yunohost app setting ${borg_id} apps | tr -d ' ') +apps=$(sudo yunohost app setting "${borg_id}" apps | tr -d ' ') for application in $(sudo ls /etc/yunohost/apps/); do - + if ( [[ "$apps" =~ ^exclude: ]] && grep -wq "$application" <<< "$apps" ) || - ( [[ "$apps" != "all" ]] && [[ ! "$apps" =~ ^exclude: ]] && ! grep -wq "$application" <<< "$apps" ); + ( [[ "$apps" != "all" ]] && [[ ! "$apps" =~ ^exclude: ]] && ! grep -wq "$application" <<< "$apps" ); then continue fi - - if sudo test ! -f /etc/yunohost/apps/$application/scripts/backup ; then + + if sudo test ! -f "/etc/yunohost/apps/$application/scripts/backup" ; then errors+="\nWarning: The application $application has no backup script. This app won't be backuped." continue fi - if ! sudo yunohost backup create -n auto_$application --method ${borg_id}_app --apps $application 2>> $err_file >> $log_file ; then + if ! sudo yunohost backup create -n "auto_$application" --method "${borg_id}_app" --apps "$application" 2>> "$err_file" >> "$log_file" ; then errors+="\nThe backup miserably failed to backup $application application." fi done @@ -67,25 +63,25 @@ done # SEND MAIL TO NOTIFY SUCCED OR FAILED OPERATIONS #========================================================= -partial_errors="$(cat $log_file | grep -E "Error|Skipped")" -if [ ! -z "$partial_errors" ]; then +partial_errors="$(cat "$log_file" | grep -E "Error|Skipped")" +if [ -n "$partial_errors" ]; then errors+="\nSome backup partially failed:\n$partial_errors" fi # Send mail on backup (partially) failed domain=$(hostname) -repository="$(sudo yunohost app setting ${borg_id} repository)" -mailalert="$(sudo yunohost app setting ${borg_id} mailalert)" -if [[ ! -z "$errors" ]]; then - sudo yunohost app setting ${borg_id} state -v "failed" +repository="$(sudo yunohost app setting "${borg_id}" repository)" +mailalert="$(sudo yunohost app setting "${borg_id}" mailalert)" +if [[ -n "$errors" ]]; then + sudo yunohost app setting "${borg_id}" state -v "failed" else - sudo yunohost app setting ${borg_id} state -v "successful" + sudo yunohost app setting "${borg_id}" state -v "successful" fi -if [[ ! -z "$errors" && $mailalert != "never" ]]; then +if [[ -n "$errors" && $mailalert != "never" ]]; then cat <(echo -e "$errors\n\n\n") "$log_file" "$err_file" | mail -s "[borg] Backup failed from $domain onto $repository" root exit 1 -elif [ $mailalert == "always" ]; then - cat $log_file | mail -s "[borg] Backup succeed from $domain onto $repository" root +elif [ "$mailalert" == "always" ]; then + cat "$log_file" | mail -s "[borg] Backup succeed from $domain onto $repository" root exit 0 fi From 9b1f830c56253568ca416501cdc23c5c8a900bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 4 May 2024 21:14:39 +0200 Subject: [PATCH 30/35] Add doc pre upgrade --- doc/PRE_UPGRADE.d/1.2.8.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 doc/PRE_UPGRADE.d/1.2.8.md diff --git a/doc/PRE_UPGRADE.d/1.2.8.md b/doc/PRE_UPGRADE.d/1.2.8.md new file mode 100644 index 0000000..4986dea --- /dev/null +++ b/doc/PRE_UPGRADE.d/1.2.8.md @@ -0,0 +1,23 @@ +This app has gone through a major revamp! + +If you have multiple instances of this app, one upgrade will break all instances. You need to +upgrade all apps. This is the last time it happens. + +Also, developer aren't flawless and we might have missed something during our tests. +Please, PLEASE, check in a few days that backups are being done properly. + +If you want to manually check backups, run this: + +```bash +systemctl start borg +``` + +Or, for a single app, for example Nextcloud: + +```bash +sudo yunohost backup create --apps nextcloud --methods borg_app +``` + +If you find *any* issue or have a doubt, feel free to contact the devs on Github or Matrix. + +Backups are important. In any case, check your backups regularly. From b9511a8ded7788ba30e1f0d5855afcdfe19224a6 Mon Sep 17 00:00:00 2001 From: Salamandar <6552989+Salamandar@users.noreply.github.com> Date: Mon, 13 May 2024 10:17:34 +0200 Subject: [PATCH 31/35] Reword post-upgrade doc for clarity. Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> --- doc/PRE_UPGRADE.d/1.2.8.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/PRE_UPGRADE.d/1.2.8.md b/doc/PRE_UPGRADE.d/1.2.8.md index 4986dea..4bd9780 100644 --- a/doc/PRE_UPGRADE.d/1.2.8.md +++ b/doc/PRE_UPGRADE.d/1.2.8.md @@ -1,12 +1,12 @@ This app has gone through a major revamp! -If you have multiple instances of this app, one upgrade will break all instances. You need to -upgrade all apps. This is the last time it happens. +The upgrade should be mainly transparent to you. However, if you have multiple instances of this app, one upgrade will break other instances and you'll need to upgrade every instance of borg installed on your server. Also, developer aren't flawless and we might have missed something during our tests. -Please, PLEASE, check in a few days that backups are being done properly. -If you want to manually check backups, run this: +We **highly** recommend to check that your backups are still being created after the upgrade. + +You can manually trigger borg backups from command line with: ```bash systemctl start borg @@ -18,6 +18,6 @@ Or, for a single app, for example Nextcloud: sudo yunohost backup create --apps nextcloud --methods borg_app ``` -If you find *any* issue or have a doubt, feel free to contact the devs on Github or Matrix. +If you find *any* issue or have a doubt, feel free to contact the YunoHost team on Github or Matrix. Backups are important. In any case, check your backups regularly. From 0352f16586db08b5b9d663ee9809c6ffb091c9ef Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 13 May 2024 08:17:38 +0000 Subject: [PATCH 32/35] Auto-update READMEs --- ALL_README.md | 1 + README_es.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++ README_zh_Hans.md | 2 +- 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 README_es.md diff --git a/ALL_README.md b/ALL_README.md index a01b345..8938aae 100644 --- a/ALL_README.md +++ b/ALL_README.md @@ -1,6 +1,7 @@ # All available README files by language - [Read the README in English](README.md) +- [Lee el README en español](README_es.md) - [Irakurri README euskaraz](README_eu.md) - [Lire le README en français](README_fr.md) - [Le o README en galego](README_gl.md) diff --git a/README_es.md b/README_es.md new file mode 100644 index 0000000..097e3cd --- /dev/null +++ b/README_es.md @@ -0,0 +1,56 @@ + + +# Borg Backup para Yunohost + +[![Nivel de integración](https://dash.yunohost.org/integration/borg.svg)](https://dash.yunohost.org/appci/app/borg) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/borg.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/borg.maintain.svg) + +[![Instalar Borg Backup con Yunhost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borg) + +*[Leer este README en otros idiomas.](./ALL_README.md)* + +> *Este paquete le permite instalarBorg Backup rapidamente y simplement en un servidor YunoHost.* +> *Si no tiene YunoHost, visita [the guide](https://yunohost.org/install) para aprender como instalarla.* + +## Descripción general + +A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) integration to backup your YunoHost server to another remote server (e.g. one of your friends). + +This app is the "client" part, meant to be installed on the server to be backed up. It works in combination with the [borg server app](https://apps.yunohost.org/app/borgserver) installed on a diffent machine. + +### Features + +- Backup on a remote machine, in comination with the [borg server app](https://apps.yunohost.org/app/borgserver) +- ... or on a [commercial borg service](https://www.borgbackup.org/support/commercial.html) +- Backups are encrypted (the remote server can't read the content) and deduplicated (optimize space) +- Backups are ran automatically, you can choose when and at which frequency +- You can choose what apps are backuped +- Receive email alerts if the backup fails (the [borg server app](https://apps.yunohost.org/app/borgserver) also checks that new content arrives and send an email to your friend otherwise) + +### Install procedure + +Maybe counter-intuitively, you should *first* install this app (`borg_ynh`) and *then* (`borgserver_ynh`) on the other machine. In fact, at the end of the install of `borg_ynh`, you will be provided with the info, in particular the SSH public key, to be used to setup `borgserver_ynh` on the other machine. + + +**Versión actual:** 1.2.8~ynh1 +## Documentaciones y recursos + +- Sitio web oficial: +- Catálogo YunoHost: +- Reportar un error: + +## Información para desarrolladores + +Por favor enviar sus correcciones a la [`branch testing`](https://github.com/YunoHost-Apps/borg_ynh/tree/testing + +Para probar la rama `testing`, sigue asÍ: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug +o +sudo yunohost app upgrade borg -u https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug +``` + +**Mas informaciones sobre el empaquetado de aplicaciones:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 82f1c76..ae401a3 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -3,7 +3,7 @@ 请勿手动编辑。 --> -# YunoHost 的 Borg Backup +# YunoHost 上的 Borg Backup [![集成程度](https://dash.yunohost.org/integration/borg.svg)](https://dash.yunohost.org/appci/app/borg) ![工作状态](https://ci-apps.yunohost.org/ci/badges/borg.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/borg.maintain.svg) From 178a24b2688b86369550cede34239c1c80a6ceb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 13 May 2024 11:29:38 +0200 Subject: [PATCH 33/35] Fix backup_method: don't use non existing activate script, use borg executable directly from the ven --- conf/backup_method | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/conf/backup_method b/conf/backup_method index d172cc2..0d9540f 100644 --- a/conf/backup_method +++ b/conf/backup_method @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -Eeuo pipefail -source "__INSTALL_DIR__/venv/bin/activate" +borg="__INSTALL_DIR__/venv/bin/borg" app="__APP__" BORG_PASSPHRASE="$(yunohost app setting "$app" passphrase)" @@ -34,7 +34,7 @@ do_backup() { current_date=$(date +"%Y-%m-%d_%H:%M") pushd "$work_dir" set +e - if borg init -e repokey "$repo" ; then + if "$borg" init -e repokey "$repo" ; then # human_size=`echo $size | awk '{ suffix=" KMGT"; for(i=1; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'` # Speed in Kbps # speed=1000 @@ -47,18 +47,18 @@ This is an automated message from your beloved YunoHost server." | /usr/bin/mail fi set -e - borg create "$repo::_${name}-${current_date}" ./ 2>&1 >/dev/null | log_with_timestamp + "$borg" create "$repo::_${name}-${current_date}" ./ 2>&1 >/dev/null | log_with_timestamp popd # About thi _20 it's a crazy fix to avoid pruning wordpress__2 # if you prune wordpress - borg prune "$repo" -P "_${name}-" --keep-hourly 2 --keep-daily=7 --keep-weekly=8 --keep-monthly=12 2>&1 >/dev/null | log_with_timestamp + "$borg" prune "$repo" -P "_${name}-" --keep-hourly 2 --keep-daily=7 --keep-weekly=8 --keep-monthly=12 2>&1 >/dev/null | log_with_timestamp # Prune legacy archive name without error on wordpress/wordpress__2 - borg prune "$repo" -P "${name}_" --keep-within 2m --keep-monthly=12 2>&1 >/dev/null | log_with_timestamp + "$borg" prune "$repo" -P "${name}_" --keep-within 2m --keep-monthly=12 2>&1 >/dev/null | log_with_timestamp # We prune potential manual backup older than 1 year - borg prune "$repo" --keep-within 1y 2>&1 >/dev/null | log_with_timestamp + "$borg" prune "$repo" --keep-within 1y 2>&1 >/dev/null | log_with_timestamp } do_mount() { @@ -69,7 +69,7 @@ do_mount() { repo="$3" size="$4" description="$5" - borg mount "$repo::$name" "$work_dir" 2>&1 >/dev/null | log_with_timestamp + "$borg" mount "$repo::$name" "$work_dir" 2>&1 >/dev/null | log_with_timestamp } work_dir="$2" From cb09827eea8cc51ec2903dd9b7225e07a3ae10f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 15 May 2024 22:33:30 +0200 Subject: [PATCH 34/35] config script: fix call to borg --- scripts/config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/config b/scripts/config index 4578046..a6972e7 100644 --- a/scripts/config +++ b/scripts/config @@ -4,6 +4,8 @@ source /usr/share/yunohost/helpers ynh_abort_if_errors +borg="$install_dir/venv/bin/borg" + #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= @@ -46,8 +48,8 @@ get__data_multimedia() { } get__last_backups() { cat << EOF -ask: |- -$(BORG_PASSPHRASE="$(ynh_app_setting_get $app passphrase)" BORG_RSH="ssh -i /root/.ssh/id_${app}_ed25519 -oStrictHostKeyChecking=yes " borg list --short --last 50 ${old[repository]} | sed 's/^/ /g' 2> /dev/null) +ask: |- +$(BORG_PASSPHRASE="$(ynh_app_setting_get $app passphrase)" BORG_RSH="ssh -i /root/.ssh/id_${app}_ed25519 -oStrictHostKeyChecking=yes " "$borg" list --short --last 50 ${old[repository]} | sed 's/^/ /g' 2> /dev/null) EOF } @@ -76,4 +78,3 @@ set__data_multimedia() { # GENERIC FINALIZATION #================================================= ynh_app_config_run $1 - From 3d91ffd4d111fa9c68a45bc4693bf7a7414f7745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 16 May 2024 13:50:12 +0200 Subject: [PATCH 35/35] Save password at install time --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index e600c07..57da313 100755 --- a/scripts/install +++ b/scripts/install @@ -34,6 +34,9 @@ ynh_app_setting_set --app=$app --key=state --value="$state" last_run="-" ynh_app_setting_set --app=$app --key=last_run --value="$last_run" +# passwords aren't saved by default +ynh_app_setting_set --app=$app --key=passphrase --value="$passphrase" + #================================================= # INSTALL BORG #=================================================