mirror of
https://github.com/YunoHost-Apps/restic_ynh.git
synced 2024-09-03 20:16:22 +02:00
59 lines
2.1 KiB
Bash
Executable file
59 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
|
|
|
ynh_setup_source --source_id=main --dest_dir="$install_dir"
|
|
chmod +x "$install_dir/restic"
|
|
|
|
chown -R "$app:$app" "$install_dir"
|
|
|
|
#=================================================
|
|
# ACTIVATE BACKUP METHODS
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up backup method..." --weight=1
|
|
|
|
mkdir -p /etc/yunohost/hooks.d/backup
|
|
mkdir -p /etc/yunohost/hooks.d/backup_method
|
|
mkdir -p /usr/share/yunohost/backup_method
|
|
|
|
ynh_restore_file --origin_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
|
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="/etc/sudoers.d/$app"
|
|
chown root:root "/etc/sudoers.d/$app"
|
|
|
|
ynh_restore --origin_path="/root/.ssh/id_${app}_ed25519"
|
|
ynh_restore --origin_path="/root/.ssh/id_${app}_ed25519.pub"
|
|
# FIXME: restore the .ssh/config instead?
|
|
_set_ssh_config
|
|
|
|
for suffix in "${systemd_services_suffixes[@]}"; do
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app$suffix.timer"
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app$suffix.service"
|
|
systemctl enable "$app$suffix.timer"
|
|
systemctl start "$app$suffix.timer"
|
|
done
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app"
|