Boot a Synology NAS, Backup Files & Shutdown

I have a server that’s on 24/7 and i have a NAS that is only required to be on to backup the video files from the 24/7 server, so i finally sat down to automate it..

Apps Required:

Wake On Lan Command Line

sleep.exe

MS RichCopy

plink

Pushbullet with the pushbullet-cli

backup.rcx is the RichCopy Profile i made (Only copies new files, Purges any old files, Creates a new log file to push to a device)


@echo off

::Wake Server
echo Waking NAS 

WolCmd.exe MAC_ADDY BroadCast_IP SUBNET 9

::wait 90secs for bootup
echo Waiting 1:30 for NAS to boot
@sleep 90

::map x: drive to nas
net use x: \\NAS_IP\PATH

::start richcopy
"C:\Program Files (x86)\Microsoft Rich Tools\RichCopy 4.0\richcopy.exe" /PF C:\BackupVideos\backup.rcx

:WAITLOOP
tasklist /FI "IMAGENAME eq richcopy64.exe" 2>NUL | find /I /N "richcopy64.exe">NUL
if "%ERRORLEVEL%"=="0" goto RUNNING
goto NOTRUNNING

:RUNNING
cls
echo *** Waiting for RichCopy to finish copy ***
@ping -n 10 127.0.0.1>nul
goto WAITLOOP

:NOTRUNNING
cls
echo *** RichCopy Finished ***

::Disconnect x: drive

net use x: /delete

::shutdown server
echo Shutting down server
plink NAS_IP -l root -pw ADMIN_PASSWORD poweroff

::Send complete push

c:\Python34\Scripts\pb.exe -d "DEVICE" LOG_FILE_LOCATION