1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/borgserver_ynh.git synced 2024-09-03 20:36:20 +02:00
borgserver_ynh/scripts/restore

48 lines
1.5 KiB
Text
Raw Normal View History

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
2018-08-31 01:11:12 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2023-12-04 20:31:10 +01:00
ynh_script_progression --message="Reinstalling borg env..."
2019-05-21 17:05:24 +02:00
install_borg_with_pip
#=================================================
# CREATE SSH USER USED BY BORG
#=================================================
2023-12-04 20:31:10 +01:00
ynh_script_progression --message="Making sure SSH user exists with appropriate permissions..."
2023-10-25 21:57:09 +02:00
ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app
home=/home/$ssh_user
2023-12-04 20:31:10 +01:00
mkdir -p $home/.ssh
chmod o=--- $home/$ssh_user
2018-06-21 17:08:18 +02:00
extra="--storage-quota $quota"
if [ "$quota" = "" ]; then
extra=""
fi
2023-12-04 20:31:10 +01:00
echo "command=\"borg serve $extra --restrict-to-repository $home/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> $home/.ssh/authorized_keys
chown -R $ssh_user:$ssh_user $home
2023-12-04 20:31:10 +01:00
# Tweak to prevent the backup of the backup itself
touch $home/.nobackup
2023-12-04 20:31:10 +01:00
# Actual restore of ...?
2018-11-29 00:08:47 +01:00
ynh_restore
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last