| Server IP : 193.86.120.172 / Your IP : 216.73.216.67 Web Server : Apache/2.4.63 (Unix) System : Linux JServices 3.10.108 #86003 SMP Wed Oct 22 13:20:46 CST 2025 x86_64 User : kubec ( 1026) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/syno/sbin/ |
Upload File : |
#!/bin/sh
. /usr/syno/share/environments.sh
. /usr/syno/share/dsmupdate/dsmupdate.subr
. /usr/syno/share/projectquota.sh
. /usr/syno/share/rootdevice.sh
RootMnt="$1"
RestoreFromABB="$RootMnt/.restore_from_abb"
RestoreFromHBED="$RootMnt/.restore_from_hbed"
if [ ! -f "$RestoreFromABB" ] && [ ! -f "$RestoreFromHBED" ] ; then
return 0
fi
CleanLocalConf()
{
Echo "clean local unuse conf for system recovery before restore"
# workaround for /var/log corsslink(project quota)
CleanupEvenIfAppendOnlyOrImmutable "$RootMnt/var/log"
Rm -rf "$CustomConfigsDir/var/log/synolog"
# remove original preference (which should be recover)
# Notice: preference might by a symlink to volume in DSM7. In this case, we will remove the link too
Rm -rf "$RootMnt/usr/syno/etc/preference"
}
ProcessCustomConfigs() # src dest
{
ConfigSrc="$1"
ConfigDest="$2"
Mkdir -p "$ConfigDest"
for config in $CustomConfigsList; do
ConfigDir=$(/bin/dirname "$config")
Mkdir -p "$ConfigDest/$ConfigDir"
Cp -af "$ConfigSrc/$config" "$ConfigDest/$ConfigDir"
done
return 0
}
Echo "Start to restore system config"
CustomConfigsList="/var/lib/brm/selected_task /var/lib/hbed/selected_task /usr/syno/etc/juniormodedata /var/log"
CustomConfigsDir="$RootMnt/.backup_process"
Echo "backup custom-configs for system recovery"
ProcessCustomConfigs "$RootMnt" "$CustomConfigsDir"
Echo "clean conf"
CleanLocalConf
Echo "restore configs..."
RestoreConfig "$RootMnt" "$RootMnt" "$(IsBtrfsRootFs && echo "no" || echo "yes" )"
Echo "restore custom-configs for system recovery"
ProcessCustomConfigs "$CustomConfigsDir" "$RootMnt"
Rm -rf "$CustomConfigsDir"
# might be useless code
if [ -d ${RootMnt}/.SynoUpgradePackages.brm ]; then
Echo "repair built-in packages for partition layout changed"
Rm -rvf ${RootMnt}/.SynoUpgradePackages
Mv -v ${RootMnt}/.SynoUpgradePackages.brm ${RootMnt}/.SynoUpgradePackages
fi
# run configupdater for different model / version
/bin/touch "$RootMnt/var/.UpgradeBootup"
/bin/touch "$RootMnt/.updater"
/bin/touch "$RootMnt/.recovery_bootup"
Rm -f "$RestoreFromABB"
Rm -f "$RestoreFromHBED"
# Reassure project ID is set on /var/log after manipulations on rootfs.
if PQMounted "${RootMnt}" ; then
touch "${RootMnt}/.project.var.log"
fi
Echo "Finish to restore system config from ActiveBackup"
return 0