1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/restic_ynh.git synced 2024-09-03 20:16:22 +02:00
This commit is contained in:
Éric Gaspar 2023-01-16 19:29:00 +01:00
parent 06a1842642
commit 0e8425bcd4
4 changed files with 11 additions and 7 deletions

View file

@ -1,5 +1,3 @@
## Overview
A [Restic](https://restic.net/) package for YunoHost (heavily inspired by [the Borg package](https://github.com/YunoHost-Apps/borg_ynh/)). A [Restic](https://restic.net/) package for YunoHost (heavily inspired by [the Borg package](https://github.com/YunoHost-Apps/borg_ynh/)).
Restic is a backup tool that can make local and remote backups. Restic is a backup tool that can make local and remote backups.

View file

@ -3,8 +3,8 @@
"id": "restic", "id": "restic",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "Backup your server with restic.", "en": "Backup your server with Restic",
"fr": "Sauvegardez votre serveur avec restic." "fr": "Sauvegardez votre serveur avec Restic"
}, },
"version": "0.12.0~ynh9", "version": "0.12.0~ynh9",
"url": "https://restic.net/", "url": "https://restic.net/",

View file

@ -76,6 +76,7 @@ ynh_configure check_method "${final_path}/check_method_${app}"
# SETUP LOG SCRIPTS # SETUP LOG SCRIPTS
#================================================= #=================================================
ynh_script_progression --message="Setting up backup log script" ynh_script_progression --message="Setting up backup log script"
ynh_configure restic_log "${final_path}/restic_log_${app}" ynh_configure restic_log "${final_path}/restic_log_${app}"
chmod +x "${final_path}/restic_log_${app}" chmod +x "${final_path}/restic_log_${app}"
chown ${app}: "${final_path}/restic_log_${app}" chown ${app}: "${final_path}/restic_log_${app}"
@ -133,6 +134,7 @@ ynh_use_logrotate --logfile=/var/log/restic_check_${app}.err
# GENERATE SSH KEY # GENERATE SSH KEY
#================================================= #=================================================
ynh_script_progression --message="Generating private key" ynh_script_progression --message="Generating private key"
ssh_dir="/root/.ssh" ssh_dir="/root/.ssh"
if [ ! -d "${ssh_dir}" ];then if [ ! -d "${ssh_dir}" ];then
mkdir -p "${ssh_dir}" mkdir -p "${ssh_dir}"
@ -164,7 +166,6 @@ ynh_script_progression --message="You should now allow the following public key
$(cat ${private_key}.pub)" $(cat ${private_key}.pub)"
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN
#================================================= #=================================================

View file

@ -30,11 +30,9 @@ export data=$(ynh_app_setting_get $app data)
export apps=$(ynh_app_setting_get $app apps) export apps=$(ynh_app_setting_get $app apps)
export allow_extra_space_use=$(ynh_app_setting_get $app allow_extra_space_use) export allow_extra_space_use=$(ynh_app_setting_get $app allow_extra_space_use)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -64,12 +62,14 @@ fi
# INSTALL RESTIC # INSTALL RESTIC
#================================================= #=================================================
ynh_script_progression --message="Installing restic binary" --weight=7 ynh_script_progression --message="Installing restic binary" --weight=7
install_restic install_restic
#================================================= #=================================================
# CREATE APP USER # CREATE APP USER
#================================================= #=================================================
ynh_script_progression --message="Creating user ${app}" ynh_script_progression --message="Creating user ${app}"
id ${app} 2>/dev/null || useradd -m ${app} id ${app} 2>/dev/null || useradd -m ${app}
ynh_script_progression --message="Configure ${app} user sudoer rights" ynh_script_progression --message="Configure ${app} user sudoer rights"
cat > /tmp/${app}_sudoer << EOSUDOER cat > /tmp/${app}_sudoer << EOSUDOER
@ -106,6 +106,7 @@ chown -R ${app}: /home/${app}
# ACTIVATE BACKUP METHODS # ACTIVATE BACKUP METHODS
#================================================= #=================================================
ynh_script_progression --message="Activating backup methods" ynh_script_progression --message="Activating backup methods"
mkdir -p /etc/yunohost/hooks.d/backup_method mkdir -p /etc/yunohost/hooks.d/backup_method
mkdir -p /usr/share/yunohost/backup_method mkdir -p /usr/share/yunohost/backup_method
@ -113,6 +114,7 @@ mkdir -p /usr/share/yunohost/backup_method
# SETUP THE BACKUP METHOD # SETUP THE BACKUP METHOD
#================================================= #=================================================
ynh_script_progression --message="Setting up backup methods" ynh_script_progression --message="Setting up backup methods"
ynh_configure backup_method "/etc/yunohost/hooks.d/backup_method/05-${app}_app" ynh_configure backup_method "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
ynh_configure check_method "${final_path}/check_method_${app}" ynh_configure check_method "${final_path}/check_method_${app}"
@ -120,6 +122,7 @@ ynh_configure check_method "${final_path}/check_method_${app}"
# SETUP LOG SCRIPTS # SETUP LOG SCRIPTS
#================================================= #=================================================
ynh_script_progression --message="Setting up backup log script" ynh_script_progression --message="Setting up backup log script"
ynh_configure restic_log "${final_path}/restic_log_${app}" ynh_configure restic_log "${final_path}/restic_log_${app}"
chmod +x "${final_path}/restic_log_${app}" chmod +x "${final_path}/restic_log_${app}"
chown ${app}: "${final_path}/restic_log_${app}" chown ${app}: "${final_path}/restic_log_${app}"
@ -133,6 +136,7 @@ chown ${app}: "${final_path}/restic_check_log_${app}"
# CONFIGURE CRON # CONFIGURE CRON
#================================================= #=================================================
ynh_script_progression --message="Configuring cron" --weight=5 ynh_script_progression --message="Configuring cron" --weight=5
ynh_configure backup-with-restic "/usr/local/bin/backup-with-${app}" ynh_configure backup-with-restic "/usr/local/bin/backup-with-${app}"
ynh_configure check-restic "${final_path}/check-${app}" ynh_configure check-restic "${final_path}/check-${app}"
chmod +x "/usr/local/bin/backup-with-${app}" chmod +x "/usr/local/bin/backup-with-${app}"
@ -189,6 +193,7 @@ fi
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring logrotate" ynh_script_progression --message="Configuring logrotate"
ynh_use_logrotate --logfile=/var/log/restic_backup_${app}.log ynh_use_logrotate --logfile=/var/log/restic_backup_${app}.log
ynh_use_logrotate --logfile=/var/log/restic_backup_${app}.err ynh_use_logrotate --logfile=/var/log/restic_backup_${app}.err
ynh_use_logrotate --logfile=/var/log/restic_check_${app}.log ynh_use_logrotate --logfile=/var/log/restic_check_${app}.log