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

65 lines
2.4 KiB
Text
Raw Normal View History

#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2022-03-13 17:45:45 +01:00
# 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
#=================================================
2024-05-25 09:34:34 +02:00
# RESTORE THE APP MAIN DIR
#=================================================
2024-05-25 09:34:34 +02:00
ynh_script_progression --message="Restoring the app main directory..." --weight=1
2021-03-07 14:03:37 +01:00
2024-05-25 22:25:00 +02:00
find '/home/yunohost.backup/tmp/Backup_test/apps/restic/backup'
2024-05-25 09:34:34 +02:00
ynh_restore_file --origin_path="$install_dir"
2024-05-25 22:20:53 +02:00
ynh_setup_source --source_id=main --dest_dir="$install_dir"
chmod +x "$install_dir/restic"
2024-05-25 09:34:34 +02:00
chown -R "$app:$app" "$install_dir"
#=================================================
# ACTIVATE BACKUP METHODS
#=================================================
2024-05-25 09:34:34 +02:00
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
2024-05-25 09:34:34 +02:00
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"
#=================================================
2024-05-25 09:34:34 +02:00
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
2024-05-25 09:34:34 +02:00
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
2022-03-13 17:45:45 +01:00
2024-05-25 09:34:34 +02:00
ynh_restore_file --origin_path="/etc/sudoers.d/$app"
chown root:root "/etc/sudoers.d/$app"
2024-05-25 09:34:34 +02:00
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
2022-03-13 17:45:45 +01:00
2024-05-25 09:34:34 +02:00
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"
2024-05-25 22:25:00 +02:00
systemctl enable --quiet "$app$suffix.timer"
2024-05-25 22:27:44 +02:00
ynh_systemd_action --service_name="$app$suffix.timer" --action="start"
2024-05-25 22:26:49 +02:00
yunohost service add "$app$suffix" --description="Restic backup program ($app$suffix)" \
--test_status="systemctl show $app$suffix.service -p ActiveState --value | grep -v failed"
2024-05-25 09:34:34 +02:00
done
2022-03-13 17:45:45 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"