Created
June 10, 2024 23:02
-
-
Save elico/62f5c4e5061e72315f9e603ae4c51bfe to your computer and use it in GitHub Desktop.
Send a rsc backup to a server over a POST request.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
/export show-sensitive file=routeros-generic-config.rsc; | |
:local deviceSerialNumber "1234"; | |
:local apiUsername "$deviceSerialNumber"; | |
:local apiPassword "secretPassword"; | |
:lcal backupServerDomain "cep-backup.ngtech.home" | |
:local fileContent [/file get routeros-generic-config.rsc contents]; | |
:local apiUrl "https://$backupServerDomain/api/v1/backup/$apiUsename/generic"; | |
:local postData "$fileContent"; | |
:local contentLength [:len $fileContent]; | |
:put $contentLength; | |
/tool fetch mode=https url=$apiUrl http-method=post \ | |
http-header-field="Content-Length: $contentLength,Content-Type: application/octet-stream" \ | |
http-data=$postData user=$apiUsername password=$apiPassword; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment