This scripts automatically shuts down a Synology NAS after a list of snapshot replication jobs have successfully completed.
- All snapshot replications need to start after midnight on the same day.
- The script will send warning messages if the tasks are not completed by 23:00.
- If the NAS is booted manually after 06:00 the script will not shut it down to allow for maintenance/administration/other tasks.
- The script is able to automatically update itself using
git.
- install the package
Git Serveron your Synology NAS, make sure it is running (requires sometimes extra action inPackage CenterandSSHrunning) - alternatively add SynoCommunity to
Package Centerand install theGitpackage (https://synocommunity.com/) - you can also use
entware(https://github.com/Entware/Entware)
- create a shared folder e. g.
sysadmin(you want to restrict access to administrators and hide it in the network) - connect via
sshto the NAS and execute the following commands
# navigate to the shared folder
cd /volume1/sysadmin
# clone the following repo
git clone https://github.com/alexanderharm/syno-shutdown-after-snapshot-replication
# to enable autoupdate
touch syno-shutdown-after-snapshot-replication/autoupdate- create a shared folder e. g.
sysadmin(you want to restrict access to administrators and hide it in the network) - copy your
synoShutdownAfterSnapshotReplication.shtosysadminusing e. g.File Stationorscp - make the script executable by connecting via
sshto the NAS and executing the following command
chmod 755 /volume1/sysadmin/synoShutdownAfterSnapshotReplication.sh- run script manually
sudo /volume1/sysadmin/syno-shutdown-after-snapshot-replication/synoShutdownAfterSnapshotReplication.sh "<sharedFolder1>" "<sharedFolder2>"AND/OR
- create a task in the
Task Schedulervia WebGUI
# Type
Scheduled task > User-defined script
# General
Task: SynoShutdownAfterSnapshotReplication
User: root
Enabled: yes
# Schedule
Run on the following days: Daily
First run time: 01:00
Frequency: Every 30 minute(s)
Last run time: 23:30
# Task Settings
Send run details by email: yes
Email: (enter the appropriate address)
Send run details only when
script terminates abnormally: yes
User-defined script: /volume1/sysadmin/syno-shutdown-after-snapshot-replication/synoShutdownAfterSnapshotReplication.sh "<sharedFolder1>" "<sharedFolder2>"