mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
Merge a43e318186
into 91ff2ae5cf
This commit is contained in:
commit
578ec61b01
6 changed files with 29 additions and 6 deletions
|
@ -17,6 +17,12 @@ The main goal of Borg is to provide an efficient and secure way to backup data.
|
|||
* Official documentation: https://borgbackup.readthedocs.io/en/stable/
|
||||
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
|
||||
|
||||
#### Customizing the backup location
|
||||
|
||||
This app lets you customize the folder in which to store your backups. However you can only choose a folder within the borgserver user home directory.
|
||||
If you want to store your backups elsewhere, like in an external drive, you could for example use the following command : `mount --bind /backup/path /home/borserver_ssh_user/repository_folder` (where `/backup/path` is your external storage and `/home/borserver_ssh_user/repository_folder` corresponds to the values you passed when installing borgserver).
|
||||
Also, you should make sure that `/backup/path` is accessible to the user created by borgserver.
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Multi-user support
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
SHELL=/bin/bash
|
||||
0 9,20 * * * root : Monitor __SSH_USER__ backup ; ALERT_DELAY="$(yunohost app setting __APP__ alert_delay)"; [[ $(find /home/__SSH_USER__/backup -follow -mtime -${ALERT_DELAY} -ls | wc -l) > 0 ]] || ( echo "No file has been backuped in /home/__SSH_USER__ since ${ALERT_DELAY} days" | mail -s "[YNH] Backup missing : __SSH_USER__" $(yunohost app setting __APP__ alert_mails))
|
||||
0 9,20 * * * root : Monitor __SSH_USER__ backup ; ALERT_DELAY="$(yunohost app setting __APP__ alert_delay)"; [[ $(find /home/__SSH_USER__/__RESPOSITORY_FOLDER__ -follow -mtime -${ALERT_DELAY} -ls | wc -l) > 0 ]] || ( echo "No file has been backed up in /home/__SSH_USER__/__RESPOSITORY_FOLDER__ since ${ALERT_DELAY} days" | mail -s "[YNH] Backup missing : __SSH_USER__" $(yunohost app setting __APP__ alert_mails))
|
||||
|
|
|
@ -30,6 +30,16 @@
|
|||
},
|
||||
"example": "john"
|
||||
},
|
||||
{
|
||||
"name": "respository_folder",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Indicate the folder in which to create backups (it will be created in the home directory of your ssh user)",
|
||||
"fr": "Indiquez le dossier dans lequel créer les sauvegardes (il sera créé dans le dossier de l'utilisateur ssh)"
|
||||
},
|
||||
"example": "my_backups",
|
||||
"default": "backup"
|
||||
},
|
||||
{
|
||||
"name": "public_key",
|
||||
"type": "string",
|
||||
|
|
|
@ -23,12 +23,12 @@ ynh_abort_if_errors
|
|||
export app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
ynh_export ssh_user public_key quota alert_delay alert_mails
|
||||
ynh_export ssh_user respository_folder public_key quota alert_delay alert_mails
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||
#=================================================
|
||||
# Here is a small hack to avoid multi install CI test to fail due
|
||||
# Here is a small hack to avoid multi install CI test to fail due
|
||||
# to same ssh_user provided
|
||||
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
|
||||
ssh_user+="$YNH_APP_INSTANCE_NUMBER"
|
||||
|
@ -39,7 +39,7 @@ ynh_system_user_exists --username=$ssh_user && ynh_die --message="This user alre
|
|||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
ynh_save_args ssh_user public_key quota alert_delay alert_mails
|
||||
ynh_save_args ssh_user respository_folder public_key quota alert_delay alert_mails
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
|
@ -70,7 +70,7 @@ extra="--storage-quota $quota"
|
|||
if [ "$quota" = "" ]; then
|
||||
extra=""
|
||||
fi
|
||||
echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> /home/$ssh_user/.ssh/authorized_keys
|
||||
echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/$respository_folder\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> /home/$ssh_user/.ssh/authorized_keys
|
||||
|
||||
#=================================================
|
||||
# AVOID BACKUP OF BACKUP
|
||||
|
|
|
@ -23,6 +23,7 @@ ynh_abort_if_errors
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
export ssh_user=$(ynh_app_setting_get $app ssh_user)
|
||||
export respository_folder=$(ynh_app_setting_get $app respository_folder)
|
||||
export public_key=$(ynh_app_setting_get $app public_key)
|
||||
export quota=$(ynh_app_setting_get $app quota)
|
||||
|
||||
|
@ -54,7 +55,7 @@ extra="--storage-quota $quota"
|
|||
if [ "$quota" = "" ]; then
|
||||
extra=""
|
||||
fi
|
||||
echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> /home/$ssh_user/.ssh/authorized_keys
|
||||
echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/$respository_folder\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> /home/$ssh_user/.ssh/authorized_keys
|
||||
|
||||
#=================================================
|
||||
# AVOID BACKUP OF BACKUP
|
||||
|
|
|
@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user)
|
||||
respository_folder=$(ynh_app_setting_get --app=$app --key=respository_folder)
|
||||
public_key=$(ynh_app_setting_get --app=$app --key=public_key)
|
||||
alert_delay=$(ynh_app_setting_get --app=$app --key=alert_delay)
|
||||
alert_mails=$(ynh_app_setting_get --app=$app --key=alert_mails)
|
||||
|
@ -77,6 +78,11 @@ if [ ! -f "/opt/borg-env/$(ynh_get_debian_release)" ] ; then
|
|||
ynh_secure_remove /opt/borg-env
|
||||
fi
|
||||
|
||||
# If respository_folder setting is missing, set it to default value
|
||||
if [ -z "$respository_folder" ]; then
|
||||
ynh_app_setting_set --app=$app --key=respository_folder --value=backup
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE SSH USER USED BY BORG
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue