Skip to content

Instantly share code, notes, and snippets.

@elico
Created June 10, 2024 23:02
Show Gist options
  • Save elico/62f5c4e5061e72315f9e603ae4c51bfe to your computer and use it in GitHub Desktop.
Save elico/62f5c4e5061e72315f9e603ae4c51bfe to your computer and use it in GitHub Desktop.
Send a rsc backup to a server over a POST request.
{
/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