mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
Allow to customize folder where to store backups.
This commit is contained in:
parent
91ff2ae5cf
commit
ab23f13cd8
4 changed files with 17 additions and 6 deletions
|
@ -1,2 +1,2 @@
|
||||||
SHELL=/bin/bash
|
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"
|
"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",
|
"name": "public_key",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -23,12 +23,12 @@ ynh_abort_if_errors
|
||||||
export app=$YNH_APP_INSTANCE_NAME
|
export app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Retrieve arguments
|
# 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
|
# 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
|
# to same ssh_user provided
|
||||||
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
|
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
|
||||||
ssh_user+="$YNH_APP_INSTANCE_NUMBER"
|
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
|
# 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
|
# INSTALL DEPENDENCIES
|
||||||
|
@ -70,7 +70,7 @@ extra="--storage-quota $quota"
|
||||||
if [ "$quota" = "" ]; then
|
if [ "$quota" = "" ]; then
|
||||||
extra=""
|
extra=""
|
||||||
fi
|
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
|
# AVOID BACKUP OF BACKUP
|
||||||
|
|
|
@ -23,6 +23,7 @@ ynh_abort_if_errors
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
export ssh_user=$(ynh_app_setting_get $app ssh_user)
|
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 public_key=$(ynh_app_setting_get $app public_key)
|
||||||
export quota=$(ynh_app_setting_get $app quota)
|
export quota=$(ynh_app_setting_get $app quota)
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ extra="--storage-quota $quota"
|
||||||
if [ "$quota" = "" ]; then
|
if [ "$quota" = "" ]; then
|
||||||
extra=""
|
extra=""
|
||||||
fi
|
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
|
# AVOID BACKUP OF BACKUP
|
||||||
|
|
Loading…
Add table
Reference in a new issue