1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/borgserver_ynh.git synced 2024-09-03 20:36:20 +02:00
This commit is contained in:
Eauchat 2021-10-01 12:24:20 +00:00 committed by GitHub
commit 578ec61b01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 6 deletions

View file

@ -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

View file

@ -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))

View file

@ -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",

View file

@ -23,7 +23,7 @@ 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
@ -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

View file

@ -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

View file

@ -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
#=================================================