Saves the results of the successful processing of shared folder synchronization to a DB file through the Log Center.
And then we're going to use SQLITE3 built-in synology to re-Script to check.
Once a normal BACKUP has been verified, the remote NAS server can be shut down via the SSH command.
The method is to create a storage destination for archiving settings in Log Center to storage destinations for archive
Select the appropriate folder (in my case, /volume2/log) to download log db files.
Archives local logs to the storage location specified above [V]. Check the and apply it.
This DB file is for SQL LITE, running sqlite3 shown in the command below, and opening the DB file specified above as an archive.
And you can know the result with a query that SELECT count the successful processing of normal synchronization today.
If the value 1 is printed on the r variable, it means that the normal performance is completed, and the backup is only done once a day.
If you have more backups, you should modify the queries and IF conditions in the script below.
In the synology, create a shell script in the shell folder using the vi editor as shown below.
vi /volume2/shell/poweroff_af_sfsync.sh
r=$(sqlite3 /volume2/log/SYNOSYSLOGDB__LOCALARCH.DB "select count(*) as cnt from logs a where host = ‘MAIN NAS' and ldate = date('now','localtime') and prog = 'NetworkBackup' and instr(msg,'Shared Folder Sync finished to sync task') > 0;")
echo $r
if [ $r -eq "0" ] ; then
echo “Shared folder sync error or Not Complete”
else
echo "End backup normally, shutting down BACKUP NAS "
ssh -p 32022 [email protected] sudo "poweroff"
fi
To automatically shut down the remote server with Wish, a copy of the pub key generation via ssh-keygen is required. For this part, please refer to the link below, which is just before the lecture.
The completed script can be registered with the work schedule, given the appropriate frequency, and checked continuously so that the remote server can be shut down if the backup succeeds.
Thank you.
And then we're going to use SQLITE3 built-in synology to re-Script to check.
Once a normal BACKUP has been verified, the remote NAS server can be shut down via the SSH command.
The method is to create a storage destination for archiving settings in Log Center to storage destinations for archive
Select the appropriate folder (in my case, /volume2/log) to download log db files.
Archives local logs to the storage location specified above [V]. Check the and apply it.
This DB file is for SQL LITE, running sqlite3 shown in the command below, and opening the DB file specified above as an archive.
And you can know the result with a query that SELECT count the successful processing of normal synchronization today.
If the value 1 is printed on the r variable, it means that the normal performance is completed, and the backup is only done once a day.
If you have more backups, you should modify the queries and IF conditions in the script below.
In the synology, create a shell script in the shell folder using the vi editor as shown below.
vi /volume2/shell/poweroff_af_sfsync.sh
r=$(sqlite3 /volume2/log/SYNOSYSLOGDB__LOCALARCH.DB "select count(*) as cnt from logs a where host = ‘MAIN NAS' and ldate = date('now','localtime') and prog = 'NetworkBackup' and instr(msg,'Shared Folder Sync finished to sync task') > 0;")
echo $r
if [ $r -eq "0" ] ; then
echo “Shared folder sync error or Not Complete”
else
echo "End backup normally, shutting down BACKUP NAS "
ssh -p 32022 [email protected] sudo "poweroff"
fi
To automatically shut down the remote server with Wish, a copy of the pub key generation via ssh-keygen is required. For this part, please refer to the link below, which is just before the lecture.
Info - How to log in without SSH password + How to log in without password
I started with a scheduler script to automatically power down the target NAS. There is a need to be controlled without a password, so I summarized what I learned after studying on the Internet for a day. The Macintosh I'm using has a terminal app installed by default. It is explained by...
www.synoforum.com
The completed script can be registered with the work schedule, given the appropriate frequency, and checked continuously so that the remote server can be shut down if the backup succeeds.
Thank you.