From aba37752282b0a4bc157c52ea5094338a640aca3 Mon Sep 17 00:00:00 2001 From: Khrys42 Date: Fri, 13 Aug 2021 18:07:37 +0200 Subject: [PATCH] Version anglaise custom_backup_methods.md --- .../custom_backup_methods.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/pages/01.administrate/07.specific_use_cases/05.backups/06.custom_backup_methods/custom_backup_methods.md b/pages/01.administrate/07.specific_use_cases/05.backups/06.custom_backup_methods/custom_backup_methods.md index 3e800fd4..5f27a37b 100644 --- a/pages/01.administrate/07.specific_use_cases/05.backups/06.custom_backup_methods/custom_backup_methods.md +++ b/pages/01.administrate/07.specific_use_cases/05.backups/06.custom_backup_methods/custom_backup_methods.md @@ -9,3 +9,50 @@ page-toc: active: true depth: 3 --- + + +It is possible to create your own backup method and link it to YunoHost's backup file collection system. This can be useful if you want to use your own backup software or conduct disk mount/dismount operations for example. + +This operation is done with a hook and will allow you to launch a backup this way: +``` +yunohost backup create --method custom +``` + +Below is a simplistic example that can be used to set up a rotational backup with different disks that are changed every week: + +/etc/yunohost/hooks.d/backup_method/05-custom +```bash +#!/bin/bash +set -euo pipefail + +work_dir="$2" +name="$3" +repo="$4" +size="$5" +description="$6" + +case "$1" in + need_mount) + # Set false if your method can itself put files in good place in your archive + true + ;; + backup) + mount /dev/sda1 /mnt/hdd + if [[ "$(df /mnt/hdd | tail -n1 | cut -d" " -f1)" != "/dev/sda1" ]] + then + exit 1 + fi + pushd "$work_dir" + current_date=$(date +"%Y-%m-%d_%H:%M") + cp -a "${work_dir}" "/mnt/hdd/${current_date}_$name" + popd + umount /mnt/hdd + ;; + *) + echo "hook called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 +```